[Cialug] Backup script, did I miss anything?

Scott Yates Scott at yatesframe.com
Wed Dec 24 15:35:31 CST 2014


Is the sqldump being compressed?
Do you want to grab your php and other assorted config files out of /etc?


On Wed, Dec 24, 2014 at 3:23 PM, Rob Cook <rdjcook at gmail.com> wrote:

> I worked up a backup script for a website that I help with, I wanted to
> have local and offsite backups just in case. I've tested the script and
> everything works for me now but I just wanted another set of eyes to take a
> look and see if I missed something.
>
> Thanks,
>
> Rob Cook
>
> #!/bin/bash
> #Define variables belowTIME=`date +%b-%d-%y`                   # This
> command will add date in backup file name.
> #WordpressWPFILENAME="websitewphtml"                # This defines the
> Wordpress backup file name.WPSRCDIR="/var/www/html/"               #
> Location of Wordpress dataDESDIR="/opt/backup"                    #
> Destination of all backup files.
> #MySQLMYSQLUSER="something"                   # MySQL
> usernameMYSQLPASSWORD="somethingelse"           # MySQL
> passwordMYSQLHOST="localhost"                   # MySQL
> hostnameMYSQLDBNAME="yetanotherthing"           # MySQL database name
>
> #LoggingLOG="/opt/backup/$WPFILENAME-$TIME.log"LOGSQL="/opt/backup/$MYSQLDBNAME-$TIME.log"
> #Actual backing up of things below
> tar -cvpzf $DESDIR/$WPFILENAME-$TIME.tar.gz $WPSRCDIR 2>&1 >> $LOG
> mysqldump -v --user=$MYSQLUSER --password=$MYSQLPASSWORD
> --host=$MYSQLHOST $MYSQLDBNAME > $DESDIR/$MYSQLDBNAME-$TIME.sql 2>
> $LOGSQL
> #Locate backups & logs more than 14 days old and delete them
> find /opt/backup/websitewphtml-*.tar.gz -maxdepth 1 -type f -mtime +14
> -delete
> find /opt/backup/yetanotherthing-*.sql -maxdepth 1 -type f -mtime +14
> -delete
> find /opt/backup/*.log -maxdepth 1 -type f -mtime +14 -delete
> #rsync backups to remote server
> rsync -avplm --delete --ignore-existing /opt/backup/ -e "ssh -p NOT22"
> SSHKEY at REMOTEIPADDRESS:/opt/backup/
> _______________________________________________
> Cialug mailing list
> Cialug at cialug.org
> http://cialug.org/mailman/listinfo/cialug
>


More information about the Cialug mailing list