View Full Version : [ubuntu] whats a popular backup script I could use???
July 13th, 2008, 08:20 AM
I want to set up nightly backups to a remote computer using rsynch. I've been looking for the most popular scripts to use, and so far have the following two below. If you know of any more well known & tested backup scripts than these can you let me know?
* HOWTO: Backup nightly via rsync (http://ubuntuforums.org/showthread.php?t=639979)
July 13th, 2008, 08:31 AM
I use my own script:
# USER VARIABLES
BACKUPDIR=/backup # Folder on the backup server where the backups shall be located
EXCLUDES=/backup/exclude_list # File containing the excluded patterns
DAYS=90 # The number of days after which old backups will be deleted
# PATH VARIABLES
SH=/bin/sh # Location of the bash bin in the production server!!!!
CP=/bin/cp; # Location of the cp bin
FIND=/usr/bin/find; # Location of the find bin
ECHO=/bin/echo; # Location of the echo bin
MK=/bin/mkdir; # Location of the mk bin
SSH=/usr/bin/ssh; # Location of the ssh bin
DATE=/bin/date; # Location of the date bin
RM=/bin/rm; # Location of the rm bin
GREP=/bin/grep; # Location of the grep bin
RSYNC=/usr/bin/rsync; # Location of the rsync bin
TOUCH=/bin/touch; # Location of the touch bin
## -- DO NOT EDIT BELOW THIS HERE -- ##
# CREATING NECESSARY FOLDERS
# CREATING CURRENT DATE / TIME
# RUN MYSQL BACKUP
# RUN RSYNC INTO CURRENT
-aplvz --delete --delete-excluded \
# UPDATE THE MTIME TO REFELCT THE SNAPSHOT TIME
# MAKE HARDLINK COPY
$CP -al $CURRENT/* $NOW
# REMOVE OLD BACKUPS
for FILE in "$( $FIND $OLD -maxdepth 1 -type d -mtime +$DAYS )"
$RM -Rf $FILE
# $ECHO $FILE
# Make MySQL Backups
# Remove old file
rm -f /mysql_backup/*
#Dump new files
for i in $(echo 'SHOW DATABASES;' | mysql -u$USER -p$PASSWORD -h$HOST|grep -v '^Database$'); do
-u$USER -p$PASSWORD -h$HOST \
-Q -e -C --add-drop-table --add-locks --quick --lock-tables \
-B $i \
$i > /mysql_backup/$i.sql;
July 13th, 2008, 08:55 AM
tks hyper_ch - what's your script roughly doing re the line "$CP -al $CURRENT/* $NOW"? It seems to be not a remote backup (just local). Can you actually recover a full set of files from say 11 days ago using this? (I see you had 90 days as limit)
July 13th, 2008, 09:05 AM
(1) of course you could make a remote backup... either use rsync over ssh use sshfs to bind the remote dir into the local filesystem....
(2) that line will make hardlinks... hence incremental snapshotstyle backups... dating back for 90 days (or whathever you wish). In "current" you have the latest backup and in "old" you have the previous ones.
July 13th, 2008, 09:12 AM
(2) that line will make hardlinks... hence incremental snapshotstyle backups... dating back for 90 days (or whathever you wish). In "current" you have the latest backup and in "old" you have the previous ones.Still don't quite understand. I looked up -al so this is archive & link.
But what happens if you modify a file over time. Wouldn't the hard link from yesterday just point to the current file and hence it wouldn't reflect how it was yesterday :confused:
July 13th, 2008, 09:18 AM
if the file is modified it makes a new entry ;)
July 13th, 2008, 09:31 AM
unfortunately the penny hasn't dropped yet for me...
I created a test file in ./new and then created a hard link via "cp -al ./new old". They have the same inodes when doing "ls -ri".
When I changed the text file in ./new and then did a "cat ./old/testfile.txt" it had also changed? This would have implied you'd lost the detail of how the file looked previously?
July 13th, 2008, 09:31 AM
rsync is not the same as editing
July 13th, 2008, 09:33 AM
oh..I'll read up on rsynch then..thanks
July 13th, 2008, 09:42 AM
September 28th, 2008, 01:06 PM
Thank you hyper_ch very much for the useful script.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.