• 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 CURDATE
    date +%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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Nice, one suggestion though : this will backup the entire db, which is not necessarily needed. For example, my host gives me access to 1 db where I put all the table I need (a few for WP and a gazillion for phpBB, for example) It would be nice to make backup on a table selection basis.

    Thanks, grfmorris.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Cronjob Backup’ is closed to new replies.