Backup Script
Date: Friday, September 17 @ 12:39:18 CDT
Topic: Tips & Tricks


Hi! I found this backup script on the web a while ago, and thought your users might like it. Should be commented enough to figure out what needs changed.

#!/bin/bash
## make sure you change this to suit your username and group names,
## plus backup locations and files to back up

date="`date +%Y-%m-%d`"
olddate="`date --date '5 months ago' +%Y-%m`"

# Zip, Create, one fiLesystem, absolute Paths, File:
## list all directories to be backed up here and location to back them up to
tar -zclPf "/backup/sysconfig-$date.tar.gz" /etc
tar -zclPf "/backup/www-$date.tar.gz" /data/www
tar -zclPf "/backup/username-$date.tar.gz" /home/username

# set permissions of backup files
chmod 600 /backup/*
## change username:usergroup to correct name:group
chown username:usergroup "/backup/username-$date.tar.gz"

# Remove all backups created 5 months ago (find -ctime could be used instead)
rm -f /backup/sysconfig-$olddate-*.tar.gz
rm -f /backup/www-$olddate-*.tar.gz
rm -f /backup/username-$olddate-*.tar.gz

# mail a message with the mail tool from the 'mail' package.
echo "Info: new backup created on `date` ($date)". | mail -s "backup created" username@localhost

submitted by anonymous user, therefore I have no idea who to give credit to this script.



This article comes from Maysville Linux Users Group (MLUG) - Linux Users Helping Linux Users
http://www.maysville-linux-users-group.org

The URL for this story is:
http://www.maysville-linux-users-group.org/modules.php?name=News&file=article&sid=4