*Update* This script was used to backup MySQL databases, however ppark1 and brunson on FedoraForum.org showed me a better method you can find here.
I'm possibly one of the most paranoid people when it comes to data safety. My home folder contains data that dates back a good five years, and although the data isn't worth anything to anyone else, I'd cry if I lost it. Although the server has RAID, this doesn't protect against accidental file deletions, and so it's always good to implement some form of backup.
Since I can't afford and don't want the hassles associated with tape backup's, I'm using a spare hard disk and a shell script to create a daily backup into a tar file for each month. The script runs every night at 3am. Every month or two, I burn the backup file to DVD for safe keeping.
The original script I use is slightly larger than the one shown below, however most of the additional lines allow me to run it in verbose mode, I'm sure you can manage to add that yourself.
#!/bin/sh backuppath="/backup/files" sourcedir="/home" curdate=`date "+%Y-%m_%B"` cd $sourcedir nice tar --ignore-failed-read --same-owner -s -p -uf $backuppath/home_$curdate.tar . cd $backuppath chown savage.savage * exit 0
The script creates a file: 'home_2005-08_August.tar'.
The first three linesftp://savnet-srv-01/public_html/content/computing/fc/tar_backup_script.php under the #!/bin/sh identifier are the variables that tell the script the location of the home directory to backup, and also the location to store the backup files.
The curdate=`date "+%Y-%m_%B"` command returns today's date in the format YYYY-MM_Month, which is then kept in the curdate variable to be used in the tar filenames.
We then change to the home directory and run the backup command, don't forget to use 'nice' as you don't want the backup process slowing down you're server (or desktop).
Finally, you probably won't need this in you're script, but I am the only person who needs access to the backups, so I change the group and owner of the backup files to my username/group. We then pass the exit value of 0.