[Gllug] rsync problems
sharon kimble
boudiccas at talktalk.net
Thu Dec 22 02:59:34 UTC 2011
On Monday 19 December 2011 05:53:28 Keith Edmunds wrote:
>
> 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
> ---------------------------------------------------------------------------
Thanks for this, its working very nicely.
>
> 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"
> ---------------------------------------------------------------------------
I tried this one out from the command line but when it completed I couldn't
find the log file! I did a sudo updatedb, and when it completed I did a locate
my_backups but couldn't find it anywhere on my system. Where did it go please?
>
> 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.
I don’t have enough bash knowledge for scripting, hence my request.
Thanks
Sharon.
--
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