Linux Blog

rsync to smb share

Filed under: General Linux — TheLinuxBlog.com at 4:30 pm on Thursday, September 11, 2008

If you happen to have a SMB share with a lot of disk space laying around, then you may have considered backing up to it. There is more than one methods that you could back up to a SMB share but this article will show how to rsync to a smb share. This blog post assumes that you have successfully set up your SMB share and have installed RSync.

Firstly, you’ll want to mount the directory locally:

[root@TheLinuxBlog.com]# mount.cifs //TheLinuxBlog/Share /mnt/Shared/ -o user=TheLinuxBlog

Once you are done you can verify that it is mounted:

[root@TheLinuxBlog.com]# mount
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
//TheLinuxBlog.com/Share on /mnt/Shared type cifs (rw,mand)
 
[root@TheLinuxBlog.com] ls /mnt/Shared
 
[root@TheLinuxBlog.com] touch /mnt/Shared/TheLinuxBlogDotCom

Once its mounted, you should be able to write to it, so try touching a file like above. Once you have verified everything is working we’re ready to move onto the rsyncing part.

[root@TheLinuxBlog.com]# rsync -avz LocalFiles /mnt/Shared/
building file list ... done
LocalFiles
rsync: chown "/mnt/Shared/.LocalFiles/.OfkB4" failed: Permission denied (13)
 
sent 69440152 bytes  received 42 bytes  957795.78 bytes/sec
total size is 70514910  speedup is 1.02
rsync error: some files could not be transferred (code 23) at main.c(977) [sender=2.6.9]

Using the -avz options in rsync recursively. If you read the rsync man page you will see why you get this error. Basically its because it trys to do it in archive mode, and I don’t have permission to change the permissions. So, if you remove the -a you should not see this error. If you need help with rsync’ing to an smb share, leave a comment and I’ll try to help you out. This wouldn’t be my preferred choice for a backup system, but if its all you have got then go for it!