wok-next rev 5677

mirror-tools/backup.sh: relative paths
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Jun 02 10:50:33 2010 +0200 (2010-06-02)
parents 4f9e5b98f4a3
children 872280fb02fc
files mirror-tools/stuff/home/backups/mirror/backup.sh
line diff
     1.1 --- a/mirror-tools/stuff/home/backups/mirror/backup.sh	Tue Jun 01 16:38:44 2010 +0200
     1.2 +++ b/mirror-tools/stuff/home/backups/mirror/backup.sh	Wed Jun 02 10:50:33 2010 +0200
     1.3 @@ -8,14 +8,15 @@
     1.4  backup_data()
     1.5  {
     1.6  while read file dirs; do
     1.7 -	find $dirs  | cpio -o -H newc | rgzip -9 > $file.cpio.gz 2> /dev/null
     1.8 +	( cd / ; find $dirs  | cpio -o -H newc ) | \
     1.9 +		rgzip -9 > $file.cpio.gz 2> /dev/null
    1.10  done <<EOT
    1.11 -etc		/etc /home/$BACKUP_USER/.ssh
    1.12 -www		/var/www/mirror-info /var/www/pizza
    1.13 -packages	/var/lib/tazpkg/installed
    1.14 -rrd		/var/spool/rrd
    1.15 -crontabs	/var/spool/cron/crontabs
    1.16 -awstats		/var/lib/awstats
    1.17 +etc		etc home/$BACKUP_USER/.ssh
    1.18 +www		var/www/mirror-info var/www/pizza
    1.19 +packages	var/lib/tazpkg/installed
    1.20 +rrd		var/spool/rrd
    1.21 +crontabs	var/spool/cron/crontabs
    1.22 +awstats		var/lib/awstats
    1.23  EOT
    1.24  }
    1.25  
    1.26 @@ -34,7 +35,9 @@
    1.27  	local i
    1.28  	local j
    1.29  	for j in $(seq $(($1 - 1)) -1 1); do
    1.30 -		for i in *.$2.$(($j - 1)) ; do mv -f $i ${i%.$2.*}.$2.$j; done
    1.31 +		for i in *.$2.$(($j - 1)) ; do
    1.32 +			[ -e $i ] && mv -f $i ${i%.$2.*}.$2.$j; done
    1.33 +		done
    1.34  	done
    1.35  }
    1.36  
    1.37 @@ -44,6 +47,7 @@
    1.38  	days=$2
    1.39  	keep=$3
    1.40  	for i in *.gz ; do
    1.41 +		[ -e $i ] || continue
    1.42  		mtime=$(( $(stat -c %Y $i) - ($days * 24 * 3600) ))
    1.43  		j=$i.$suffix.0
    1.44  		[ -e $j ] && [ $(stat -c %Y $j) -gt $mtime ] && continue
    1.45 @@ -53,7 +57,9 @@
    1.46  done
    1.47  if [ 0$KEEP -gt 0 ]; then
    1.48  	[ $KEEP -gt 1 ] && rotate $KEEP gz
    1.49 -	for i in *.gz ; do mv -f $i $i.0; done
    1.50 +	for i in *.gz ; do
    1.51 +		[ -e $i ] && mv -f $i $i.0
    1.52 +	done
    1.53  fi
    1.54  
    1.55  backup_data
    1.56 @@ -61,7 +67,7 @@
    1.57  chown $BACKUP_USER *
    1.58  chmod 700 *
    1.59  
    1.60 -for i in $(cd .. ; ls); do
    1.61 +[ -n "$REMOTE_USER" ] && for i in $(cd .. ; ls); do
    1.62  	[ $i == $(hostname) ] && continue
    1.63  	rsync -aH -e "$SSH" --bwlimit=50 $REMOTE_USER@$i.slitaz.org:/home/backups/$i/. ../$i/.
    1.64  done