X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=backup.sh;h=307a14f23aae338f15b76d4c795aa0823ccdd180;hb=040ea36adf3804e541e9973d88c2168da11e8eae;hp=e7c04c0f9b06183156dbf798fc8638278b80e7a4;hpb=a2863a4217f657c16498a5266ea3aee7df5a2a52;p=backup.sh diff --git a/backup.sh b/backup.sh index e7c04c0..307a14f 100755 --- a/backup.sh +++ b/backup.sh @@ -68,9 +68,6 @@ echo `date`": Backup run starting" >&2 umask 027 -#selve backupen -# krever at noen variabler er satt -# krever at vi er i rett katalog backup() { @@ -133,7 +130,7 @@ backup() # Update timestamp echo $DATEs > ../.date && touch -t $DATE ../.date - # Make a sorted filelist as well + # Make a sorted file list as well sort -k6 < $DATE.idx > $DATE.sdx # Fix permissions @@ -147,8 +144,6 @@ backup() # Something wrong happened. rm $TARFILE echo `date`" $computer: $TARFILE empty. $backuplevel backup of $computer:$filesystem failed and deleted" - - # We don't want to return 0 die fi @@ -172,8 +167,6 @@ backup() # Try to SSH to the computer without entering a password. if ! `ssh -n -o NumberOfPasswordPrompts=0 root@$computer /bin/true`; then echo `date`" $computer: Could not use passwordless SSH." - - # We don't want to return 0 die fi @@ -185,8 +178,6 @@ backup() compressor=gzip fi - filesystems="" - # Check dump bit in fstab filesystems=`ssh -n root@$computer "cat /etc/fstab" \ | grep -v nfs \ @@ -196,33 +187,33 @@ backup() # Clean up our dir at this client if ! ssh root@$computer "rm -r ~/.backup ; mkdir -m 700 ~/.backup"; then - echo `date`" $computer: Could not create backup staging area at $computer:~/.backup - skipping backup of $computer" + echo `date`" $computer: Could not create backup staging area at $computer:~/.backup" die fi # Try to copy $exclude to $computer if ! scp $exclude root@$computer:~/.backup/exclude > /dev/null; then - echo `date`" $computer: Could not copy exclude.txt to $computer - skipping backup of $computer" + echo `date`" $computer: Could not copy exclude.txt to $computer" die fi # Try to copy preeexec and postexec if they exist if [ -f $confdir/preexec.$computer ]; then if ! scp $confdir/preexec.$computer root@$computer:~/.backup/preexec >&2; then - echo `date`" $computer: Could not copy preexec.$computer to $computer:~/.backup/preexec - skipping backup of $computer" + echo `date`" $computer: Could not copy preexec.$computer to $computer:~/.backup/preexec" die fi fi if [ -f $confdir/postexec.$computer ]; then if ! scp $confdir/postexec.$computer root@$computer:~/.backup/postexec >&2; then - echo `date`" $computer: Could not copy postexec.$computer to $computer:~/.backup/postexec - skipping backup of $computer" + echo `date`" $computer: Could not copy postexec.$computer to $computer:~/.backup/postexec" die fi fi - # Try to run preexec if it exist + # Try to run preexec if it exists if ! ssh root@$computer "[ ! -f ~/.backup/preexec ] || /bin/bash -x ~/.backup/preexec" >&2; then - echo `date`" $computer: Could not run $computer:~/.backup/preexec - skipping backup of $computer" + echo `date`" $computer: Could not run $computer:~/.backup/preexec" die fi @@ -235,8 +226,6 @@ backup() # Prepare storage area mkdir -m 755 -p $storagedir/$computer/$sfilesystem/full 2>/dev/null mkdir -m 755 -p $storagedir/$computer/$sfilesystem/daglig 2>/dev/null - echo $filesystem > ${storagedir}/${computer}/.${sfilesystem}.name - chmod 644 ${storagedir}/${computer}/.${sfilesystem}.name # Default backuplevel backuplevel=daglig @@ -248,8 +237,7 @@ backup() echo $DATEs > $storagedir/$computer/$sfilesystem/.date fi - # Check if we want a full backup - Debug statement that causes noise in cron mail: - # printf " $computer $filesystem: $confdir/fastfullbackupdag.$computer.$sfilesystem\n" + # Check if we want a full backup if [ -f $confdir/fastfullbackupdag.$computer.$sfilesystem ]; then fullbackup_min_for_this_machine=$dagermellomfulleforfast if [ "$DAY_OF_MONTH" = "`cat $confdir/fastfullbackupdag.$computer.$sfilesystem`" ]; then