Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # creates backups of essential files
- #
- DATA="/home /root /usr/local/httpd"
- CONFIG="/etc /var/lib /var/named"
- LIST="/tmp/backlist_$$.txt"
- #
- mount /mnt/backup
- set $(date)
- #
- if test "$1" = "Sun" ; then
- # weekly a full backup of all data and config. settings:
- #
- tar cfz "/mnt/backup/data/data_full_$6-$2-$3.tgz" $DATA
- rm -f /mnt/backup/data/data_diff*
- #
- tar cfz "/mnt/backup/config/config_full_$6-$2-$3.tgz" $CONFIG
- rm -f /mnt/backup/config/config_diff*
- else
- # incremental backup:
- #
- find $DATA -depth -type f \( -ctime -1 -o -mtime -1 \) -print > $LIST
- tar cfzT "/mnt/backup/data/data_diff_$6-$2-$3.tgz" "$LIST"
- rm -f "$LIST"
- #
- find $CONFIG -depth -type f \( -ctime -1 -o -mtime -1 \) -print > $LIST
- tar cfzT "/mnt/backup/config/config_diff_$6-$2-$3.tgz" "$LIST"
- rm -f "$LIST"
- fi
- #
- # create sql dump of databases:
- mysqldump -u root --password=mypass --opt mydb > "/mnt/backup/database/mydb_$6-$2-$3.sql"
- gzip "/mnt/backup/database/mydb_$6-$2-$3.sql"
- #
- umount /mnt/backup
Add Comment
Please, Sign In to add comment