Wednesday, May 7, 2008

NAS Backup

http://www.openmss.org/forum/viewtopic.php?f=10&t=1016#p4764

I bought a Maxtor Shared Storage II 1 TB network attached storage device. It runs a Linux operating system and comes setup with Samba which is really all you need to back up to the device.

Plug in the NAS and connect to your network. There is one predefined share on the NAS that will show up in Network Places in Windows.

The NAS will get an IP address from DHCP. In Windows open the My Network Places folder. You will be able to see the IP address of the NAS. Open a browser and type in the address. You will be looking at the configuration utility for the NAS.

Set up device name and password. I called mine maxtor1. The second one is called maxtor2.
Set up NTS
Set up TCP/IP. Assign a static IP address and add it to /etc/hosts on the DNS server.
Set up a user. You will use these credentials to connect from the server to the NAS.
Set up a share. I called mine "backup".


On the server edit /etc/samba/smbfstab to mount the network drive
Linux Reality Episode 25 had instructions on how to do this, but they didn't work exactly for me. Apparently for newer Linux kernels and versions of Samba, smbmount has been replaced by cifs. The following instructions are what I had to do for openSUSE 10.3 with Linux kernel 2.6.22 and Samba 3.0.26a.

//maxtor1/backup /home/backup cifs username=user,password=foobar -o rw

mount -t cifs \\\\maxtor1\\backup /home/backup

where
//maxtor1/backup is the share to be mounted
/home/backup is the folder to mount to
cifs is the vfstype. This can be either cifs or smbfs, but smbfs did not work for me
username and password are the username and password for the folder on the NAS
-o marks the beginning of the options section
rw makes the mount read write

IMPORTANT: smbfstab has 0600 permissions, meaning only root can read it. fstab has 0644 permissions meaning anyone can read it. This means it is OK to put the username and password in smbfstab, but if you are using fstab you will want to use the credentials option. This is well discussed in Linux Reality Episode 25.

Then either reboot or type
#mount -a

You should now have access to maxtor1 through the folder /home/backup. If you were to create a folder on the share on maxtor1 called pictures you would see it as /home/backup/pictures.

I copy data to an external drive using rsync. The rsync command line I use is

#rsync -av --delete /home/documents/ /home/backup/

-a is the archive flag and it invokes a bunch of flags that are good for archiving.
v is the verbose flag. One v will output the files that are changed, added or deleted.
--delete will delete files out of the backup set if they have been deleted from the primary data set.
type "$man rsync" for more info.


Things to do
Add rsync to cron (as root)

No comments: