You are not logged in.

#1 2011-12-23 18:22:35

airbus001
Member
Registered: 2011-09-29
Posts: 17

Backup Script Problems

Hello,

I am writing a backup script to backup my whole / directory, however I am running into what seems to me to be unexplainable problems:

backup.sh:

#!/bin/bash
#rsync back up script

while [ 1 ]; do     #loop until rsync runs
    if ! grep -q backup /proc/mounts; then      #checks if the backup partition is mounted
	espeak "The backup partition is not mounted. Please mount it as the script will try to run in one minute."
    else
	sudo bash -c    #takes argument $1
	"
        rsync -auH --inplace --exclude-from=/home/maddog/backup.lst / $1 >> /var/log/backup.log;
        pacman -Qqe > $1/prog.lst;
        "
	break
    fi
    sleep 1m
done

Output of running "sh ./backup.sh /media/backup":

Password: 
bash: -c: option requires an argument
./backup.sh: line 12: 
        rsync -auH --inplace --exclude-from=/home/maddog/backup.lst /  >> /var/log/backup.log;
        pacman -Qqe > /prog.lst;
        : No such file or directory

However both files do indeed exist. If I remove the pacman line, I still get an error about /var/log/backup.log not existing. Note the sudo bash is requied as I am io-redirecting to files owned by root.
Another concern is if I run this script in cron how can I make sure that I don't shutdown the computer while the script is running?


Any help would be greatly appreciated.
Thanks,
airbus001

Offline

#2 2011-12-24 01:15:54

airbus001
Member
Registered: 2011-09-29
Posts: 17

Re: Backup Script Problems

I fixed the problem the main problem was the placement of the first quotation mark, if anyone wants my script message me.

Offline

Board footer

Powered by FluxBB