Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #backup.sh
- timestamp=`date "+%Y-%m-%d-%H-%M"`
- backupFS="/path/to/source/folder"
- backupTO=/path/to/destination/folder
- KeepTime=7
- if [ -d $backupTO ];
- then
- find $backupTO -maxdepth 1 -name \*.tar.gz -mtime +${KeepTime} -exec rm -f {} \;
- for i in $backupFS
- do
- j=`expr ${i//\//-}`
- tar -zcvpf $backupTO/`hostname`.${timestamp}.${j}.tar.gz $i
- echo "$i is done"
- done
- else
- echo "backup directory is missing..exiting"
- exit 1
- fi
Advertisement
Add Comment
Please, Sign In to add comment