> Yes, if you remove the --delete parameter to the rsync call, then it
> will not delete files that no longer exist in the source file system. At > RTI I don't use --delete when backing up certain project shares, to >protect against users' "accidental" file deletions. Of course, you end up >with a backup archive that is much larger than the source file system this >way. With the --delete parameter, the backup is an exact mirror of the >source. There's a decent article on using Rsync for (tiered) snapshot-style backups here; http://www.mikerubel.org/computers/rsync_snapshots/#Extensions which allows for versioned backups. The other advantage of Rsync is that it also supports SSH, which when coupled with SSH keys works nicely for remote/automated backups via an encrypted tunnel; #!/bin/bash # nickf database backup script January 2008 # usage: mysqldump -a -u USERNAME -p DATABASE > FILENAME.mysql # back-up the MySQL databases USER=<username redacted> PWD=<removed by nickf for emailing> MYSQLCMD="/usr/bin/mysql" MYSQLDUMP="/usr/bin/mysqldump" RSYNC="/usr/bin/rsync" #DBLISTFILE=list_of_databases.txt TMPFILE=`/bin/mktemp /tmp/dblist-nickf.XXXXXXXXXXXX` #echo $TMPFILE # remove the backup script template if exists if [ -f backup-script.sh ] ; then rm backup-script.sh else echo "hi" > /dev/null fi # generate a list of MySQL databases, remove "Database" header, and put in a file # $MYSQLCMD -e "show databases;" -u $USER -p<removed> |egrep -v "Database" > $TMPFILE # touch a backup script template. /usr/bin/touch backup-script.sh ; chmod 744 backup-script.sh # add the BASH script header for files in backup-script.sh do ed -s backup-script.sh << TEXT 0,a #!/bin/bash # backup script template, automatically generated # DO NOT EDIT THIS FILE! rather, edit the backup-database-nickf.sh template generator # . w q TEXT done # put the MySQL dump actions into the backup script template cat $TMPFILE | awk -v RS="\n" '{print "/usr/bin/mysqldump -a -u username -p<password-removed>", $1, ">",$1".mysql" }' >> backup- script.sh # create the MySQL database backups from the generated script template if [ -f backup-script.sh ] ; then ./backup-script.sh fi # push the MySQL database backups off-site # $RSYNC -avur -e "ssh -i /home/username/.ssh/username-backup-key" *.mysql [hidden email]:backups # # get rid of our trash for files in `ls /tmp/dblist-nickf.XXXXXX*` ; do rm $files ; done # remove mysqldumps for files in *.mysql ; do rm $files ; done # back up the username homedir, web site and code tree $RSYNC -avur -e "ssh -i /home/username/.ssh/username-backup-key" /home/ username [hidden email]:backups/ # remove the backup script template if [ -f backup-script.sh ] ; then rm backup-script.sh else echo "hi" > /dev/null fi ============================================================ FRIAM Applied Complexity Group listserv Meets Fridays 9a-11:30 at cafe at St. John's College lectures, archives, unsubscribe, maps at http://www.friam.org |
Free forum by Nabble | Edit this page |