[Gllug] rsync problems

sharon kimble boudiccas at talktalk.net
Mon Dec 19 12:50:47 UTC 2011


On Monday 19 December 2011 05:53:28 Keith Edmunds wrote:
> I suspect the problem is that the destination directory doesn't exist.
> 
The script creates the backup folder when first run at midnight, so it doesn’t 
exist until then. 

> What username are you running the scrip as?

boztu

> What filesystem is on the external disk?

ext3

I'll certainly implement your new script later on today, many thanks

Sharon.
> 
> Here's a slightly modified version of the script. It uses some symbols to
> make the script more readable, and avoids the backticks. It tries to
> create the destination directory before running if necessary, although
> that step will fail if the user running the script has insufficient
> permissions. Finally, it writes any errors to your log file, so you'll be
> able to see why things fail (if they still do).
> 
> ---------------------------------------------------------------------------
> ----- #!/bin/bash -x #shell script for use with rsync in user crontab
> 
> USB_DIR="/media/8eef3b99-c17b-4913-ae61-d34c7fd5d459"
> BACKUP_DIR="$USB_DIR/$(/bin/date +%Y%m%d)"
> 
> if [ -d $USB_DIR ]; then
> 	[ -d $BACKUP_DIR ] || mkdir $BACKUP_DIR \
> 
> 		>> /home/boztu/cron/backup.txt 2>&1
> 
> 	/usr/bin/rsync -avz \
> 		--exclude-from '/home/boztu/cron/xclude.txt' \
> 		/home/boztu/ $BACKUP_DIR \
> 
>    		>> /home/boztu/cron/backup.txt 2>&1
> 
> fi
> ---------------------------------------------------------------------------
> -----
> 
> Personally, I would log the output of such a script to syslog, which means
> it will be automatically time-stamped and log-rotated. This is how I would
> do that:
> 
> ---------------------------------------------------------------------------
> ----- #!/bin/bash -x #shell script for use with rsync in user crontab
> 
> USB_DIR="/media/8eef3b99-c17b-4913-ae61-d34c7fd5d459"
> BACKUP_DIR="$USB_DIR/$(/bin/date +%Y%m%d)"
> LOG="/usr/bin/logger -t my_backups"
> 
> $LOG "Backup starting"
> if [ -d $USB_DIR ]; then
> 	[ -d $BACKUP_DIR ] || mkdir $BACKUP_DIR \
> 		2>&1 | $LOG
> 	/usr/bin/rsync -avz \
> 		--exclude-from '/home/boztu/cron/xclude.txt' \
> 		/home/boztu/ $BACKUP_DIR 2>&1 | $LOG
> fi
> $LOG "Backup finished"
> ---------------------------------------------------------------------------
> -----
> 
> Please note that I've not tested either script above. You should ensure
> that you understand and test them (and fix them if necessary) before
> relying on them.

-- 
A taste of linux = http://www.sharons.org.uk/taste/index.html
efever = http://www.efever.blogspot.com/
efever = http://sharon04.livejournal.com/
Debian 6,0.3, Gnome 1:2.30+7, LibreOffice 3.4.4
Registered Linux user 334501 
--
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list