Cronjob Backup
-
I mentioned a loooooong time ago that I would share a backup script that could be run via crontab.
Here it is. If you don’t know how shell scripts work, I’m not the person to ask. 🙂
Below, any instance of a tilde [~] indicates /home/[username]/. Referencing to user root is key to this. You could change it to /home/[username]/ if you so chose.
#!/bin/csh -f
# Determine current date
setenv CURDATEdate +%Y%m%d
# Backup all WP databases to compressed, dated file in home directory
mysqldump -q -e -hlocalhost -u[user] -p[pass] [database] | gzip - > ~/${CURDATE}_db-backup.sql.gz
# Backup WP files to compressed, dated file in home directory
cd ~/public_html
tar cf - . | gzip - > ~/${CURDATE}_files.tar.gz…
Any data in [brackets] should be filled in.
This should sit in userroot, chmod’d to 755 to be executable.
You will get errors for all files in wp-uploads on the second TAR run for the backups. If you don’t want backups of your WP files but are more concerned about the backup of the database, remove everything from the last comment on down.
The topic ‘Cronjob Backup’ is closed to new replies.