Simple & Cool backup script

Here is a cool script, used to backup this site and a few others hosted here. The script should be self explanatory.


# First, archive the older backups.
for file in public_html mail database.mysql; do
for number in 6 5 4 3 2 1 ; do
  if [ -f "$HOME"/backup/"$file"."$number".tar.gz ] ; then
   mv "$HOME"/backup/"$file"."$number".tar.gz "$HOME"/backup/"$file".$(($number + 1)).tar.gz
if [ -f "$HOME"/backup/"$file".tar.gz ] ; then
  mv "$HOME"/backup/"$file".tar.gz "$HOME"/backup/"$file".1.tar.gz

# Now create new backups for files.
cd $HOME
tar -czf $HOME/backup/public_html.tar.gz public_html
tar -czf $HOME/backup/mail.tar.gz mail

# And create new backups for mysql.
for database in database ; do
mysqldump -u username -ppassword "$database" > "$HOME"/backup/"$database".mysql && tar -czf "$HOME"/backup/"$database".mysql.tar.gz backup/"$database".mysql
rm "$HOME"/backup/"$database".mysql

Some modifications have been made for publishing, not to reveal to much information...