Archive for September 14th, 2007

Backup Script (shell)

Backup same directories or files and compress them with tar.gz

#!/bin/bash
#
# creates backups of essential files
#
TRAC="/opt/trac_root"
SVN="/opt/svn_root"
SMB="/opt/smb_root"
LIST="/tmp/backlist_$$.txt"
 
 
set $(date)
 
 
 
 
 
# full backup: TRAC / SVN
#
tar cfz "/var/MyBackup/trac/trac_full_$6-$2-$3.tgz" $TRAC
#
tar cfz "/var/MyBackup/svn/svn_full_$6-$2-$3.tgz" $SVN
 
 
 
 
 
if test "$1" = "dim" ; then
        # weekly a full backup of smb
        #
        tar cfz "/var/MyBackup/smb/smb_full_$6-$2-$3.tgz" $SMB
        rm -f /var/MyBackup/smb/smb_diff*
else
        # incremental backup:
        #
        find $SMB -depth -type f  \( -ctime -1 -o -mtime -1 \) -print > $LIST
        tar cfzT "/var/MyBackup/smb/smb_diff_$6-$2-$3.tgz" "$LIST"
        rm -f "$LIST"
fi