All pastes #273310 Raw Edit

Roconda

public shellscript v1 · immutable
·published 2006-12-09 20:14 UTC
rendered paste body
#!bin/bash#RoQ-up v.0.1.2 made by Roconda (Tim Slot) feedback: Tim.Slot@gmail.com#This script will backup by default your home dir to /usr/backup#This script is free software; you can redistribute it and/or#modify it under the terms of the GNU General Public License#as published by the Free Software Foundation; either version 2#of the License, or (at your option) any later version.#This script is distributed in the hope that it will be useful,#but WITHOUT ANY WARRANTY; without even the implied warranty of#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the#GNU General Public License for more details.#You should have received a copy of the GNU General Public License#along with this program; if not, write to the Free Software#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.#BEGIN CONFIGhomedir="$PWD" # You can change this to the map which have to be backed-upbackupstorage="/usr/backup"cron="0" # 0 = no || 1 = yesdate=$(date +%F) # Do not change it unless you know what you are doing#END OF CONFIG#TODO:#-building ftp support, like transfering to a ftp/storage server. - release date: 00-00-00#DO NOT CHANGE THIS CODE WITHOUT KNOWING WHAT YOU ARE DOING!if [  `id -u` != "0" ] ; then		echo "--< ERROR >--	You have to be root"	exit 1fiif [ ! -d "$backupstorage" ] ; then	/bin/mkdir $backupstorage		echo "--< DONE >--	Build $backupstorage, please execute this script again"	exit 1fiif [ -e "$backupstorage/backup-$date.tar.gz" ] ; then                echo "--< ERROR >--     File already exist"        exit 1fiif [ "$cron" = "1" ] ; then	tar -czvf $backupstorage/backup-$date.tar.gz $homedir	size=`ls -sh --color=none $backupstorage/backup-$date.tar.gz | egrep -o '^[0-9.PTGMKB]+'`          		echo "--------------Cron----------------" >> ~/backup.log		date >> ~/backup.log                echo "Saved as: backup-$date.tar.gz" >> ~/backup.log                echo "Compressed size: $size" >> ~/backup.log                echo "----------------------------------" >> ~/backup.log	exit 0fi		echo "--< BUILDING >--	Backing-up $homedir"		tar -czvf $backupstorage/backup-$date.tar.gz $homedir		size=`ls -sh --color=none $backupstorage/backup-$date.tar.gz | egrep -o '^[0-9.PTGMKB]+'`          		echo 		echo "--< DONE >--	Backed-up $homedir to $backupstorage"		echo 		echo "----------------------------------" >> ~/backup.log		date >> ~/backup.log		echo "Backup from: $homedir" >> ~/backup.log		echo "Backup to: $backupstorage" >> ~/backup.log		echo "Saved as: backup-$date.tar.gz" >> ~/backup.log		echo "Compressed size: $size" >> ~/backup.log		echo "----------------------------------" >> ~/backup.log		tail -n 7 ~/backup.log			exit 0