rsync from linux to smb device (ie: mybook, windows computer, etc..)



Ok, so you went out and bought network access storage like a mybook - or you've got a windows server that everyone backs up to. You'd like to set up rsync to backup your stuff to it! Simple - follow these instructions!

I'm currently using this to back-up to my 'mybook live' NAS. Why didn't they just add ssh support in the one I have?? Oh well - this is just as simple...

FIrst, make a mount point:

mkdir /mnt/share

Then, mount your smb share:

mount.cifs // /mnt/share -o user=username

It'll prompt you for a password (you want to stay away from typing passwords within commands when you can!)

Verify it's mounted by using the mount command:

// on /mnt/share type cifs (rw)

Want to do it automagically at every boot? Add it to /etc/fstab:

//    /mnt/share        smbfs    username=rob,password=SuPeRdUpEr 0 0

Now you can rsync stuff to it - let's rsync rob's home directory into a dir called 'homedir':

rsync -avz /home/rob/ /mnt/share/homedir/

Now, if you really want to get fancy and feel all backed up all the time, add an rsync to crontab!

crontab -e

And add your rsync line to go every night at 2am (or whenever) w/o emailing root anything..

* 2 * * * /usr/bin/rsync -avz /home/rob/ /mnt/share/homedir/ >/dev/null 2>&1

One thing to make sure of though - ensure that your NAS will always come up under that same ip address or your system won't be able to mount it - and you'll be rsyncing your home directory into your /mnt/share/homedir on your local system.
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Members online

Latest posts