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

R

Rob

Guest
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:

Code:
mkdir /mnt/share

Then, mount your smb share:

Code:
mount.cifs //192.168.0.6/sharename /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:


Code:
mount
//192.168.0.6/sharename on /mnt/share type cifs (rw)


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

Code:
//192.168.0.6/share    /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':

Code:
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!

Code:
crontab -e

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

Code:
* 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

Top