In general, your files are NOT backed-up. Be assured that harddisks DO
crash. To avoid loss of weeks or months of work you should make sure to
back-up stuff yourself. An example for (almost) brute force automated
nightly back-up is given here:
I. Create a file c1
In c1 type the rsync commands to create your backup.
Here is an example for backing up /my_disk/my_uname/my_data on /backup_disk/my_uname/data_backup
(e.g. /vol/archive/xray).
Note: You will need to create the proper directory structure first.
(1) At the beginning of your c1 file copy the following function:
random_sleep()
{
RandomSleep=3600
if [ $RandomSleep -eq 0 ]; then
return
fi
if [ -z "$RANDOM" ] ; then
# A fix for shells that do not have this bash feature.
RANDOM=$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -c"1-5")
fi
TIME=$(($RANDOM % $RandomSleep))
sleep $TIME
}
(2) Get rid of old backup log file:
rm -f /backup_disk/my_uname/Rsync_logs/data_backup_old.asc
(3) Move current backup log file to old.
mv -f /backup_disk/my_uname/Rsync_logs/data_backup.asc
/backup_disk/my_uname/Rsync_logs/data_backup_old.asc
(4) use rsync to create backup.
rsync -avzu --delete --force --stats --modify-window 5 /my_disk/my_uname/my_data/
/backup_disk/my_uname/data_backup
(5) chmod
chmod 700 /backup_disk/my_uname/data_backup
Note: the --delete switch means that files that have been
removed will be deleted in the new backup.
If you do not wish this to happen (e.g. in case you want to recover old
files), remove the --delete switch. However, in this case you
need to keep an eye
on your backup so it does not fill up the disk, preventing new data
from being backed up.
Another useful switch is --exclude-from which allows you to
exclude directories that you do not wish to back-up (e.g. large data
sets that are easily replaceable).
The syntax is --exclude-from=/path/to/file/which/lists/excluded/files/and/directories.
See the man page for additional possible switches.
II Create a file table.asc
Enter the time you wish the backup to be taken. You probably also want
to add some comments saying what the file is:
# crontab
# Load: crontab table.asc
# List: crontab -l
#min hour day month dow command
22 02 * * * /your/path/to/c1
The "*" indicates it should be done every day, month, and day of the
week.
Type: crontab table.asc
and you're done!
Examples
You can find further examples of rsync commands here:
/vol/aibn154/data1/reiprich/Programming/cron/c1
Example cron tab for automated execution:
/vol/aibn154/data1/reiprich/Programming/cron/table.asc
Last Updated 2015-June-9 by Lorenzo Lovisari