[Klug-general] rsync and usb

sharon kimble boudiccas at talktalk.net
Mon Sep 26 23:08:09 UTC 2011


On Monday 26 September 2011 08:46:22 David Halliday wrote:
> Good morning,
> 
> Looking at the two commands:
> /usr/bin/rsync -av /home/boztu/ */media/disk/*`/bin/date +%Y%m%d`/ >>
> /home/boztu/cron/backup.txt
> /usr/bin/rsync -av /home/boztu/ */media/usb/*`/bin/date +%Y%m%d`/ >>
> /home/boztu/cron/backup.txt
> 
> The only difference i can see is the name of the directory where the device
> is mounted. This might be a case of checking the fstab:
> http://www.tuxfiles.org/linuxhelp/fstab.html
> 
> Te enable both of these to run (or the right one to run) you can use an if
> statement to detect which target directory exists:
> if [ -d /media/disk/ ]; then
>    /usr/bin/rsync -av /home/boztu/ /media/disk/`/bin/date +%Y%m%d`/ \
> 
>    >> /home/boztu/cron/backup.txt
> 
> fi
> 
> if [ -d /media/usb/ ]; then
>    /usr/bin/rsync -av /home/boztu/ /media/usb/`/bin/date +%Y%m%d`/ \
> 
>    >> /home/boztu/cron/backup.txt
> 
> fi
Thanks David, I've got this working and I hope it survives a reboot, I can't 
see any reason why it shouldn't.

Thanks
Sharon.  
> On 25 September 2011 23:20, sharon kimble <boudiccas at talktalk.net> wrote:
> > I use rsync to back up my /home to an external hard drive using usb. 
> > Thiis the stanza;= /usr/bin/rsync -av /home/boztu/
> > /media/disk/`/bin/date +%Y%m%d`/
> > 
> > >> /home/boztu/cron/backup.txt
> > 
> > But occasionally when I plug the drive in after a reboot, it comes up
> > with ;=
> > /usr/bin/rsync -av /home/boztu/ /media/usb/`/bin/date +%Y%m%d`/ >>
> > /home/boztu/cron/backup.txt
> > 
> > How can I add the second line to my backup.sh file such that it will run
> > from
> > either stanza please?
> > 
> > Take care
-- 
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.2, KDE 4.4.5, LibreOffice 3.4.3
Registered Linux user 334501 



More information about the Kent mailing list