by Rob Williams on August 27, 2007 in Linux
Backing up your computer is important. Don’t be the sucker who loses important files and has to deal with it afterwards! In this how-to, you will learn about using rsync and lftp, writing your own scripts and adding them to crontab and of course, backing up to your external storage, NAS and also a remote server running Linux.
Network-Attached Storage (NAS) is a rather new technology, but is becoming more popular by the day. Simply put, a NAS box is an appliance that connects to your router like a normal computer. Inside is an installed hard-drive, or two, depending on your model. Once installed, you will be able to access the box on your network just as if it were another PC. The great thing about NAS, and the reason it’s included in this article, is that it’s a handy way to securely backup your important files. If your computer blows up, at least the NAS is there to save you.
Because a NAS is a network device, we are going to use Samba to connect to it. Some NAS products pre-install SSH and FTP support, and if that’s the case, you could simply use SSH to connect instead of Samba. But for the sake of assuming that most NAS boxes do not support SSH (only the expensive ones do), we will stick to what most already have installed on their machines.
In order to mount our network drive, we are going to need the Samba Filesystem support. To see if you have support on your machine already, look under your /sbin to see: ls -l /sbin/mount.smbfs. If you do, skip this step. If not, you will need to go into your kernel and install it. If you are unsure how to compile a kernel, or grab kernel sources, refer to your distributions wiki or how-to pages.
As superuser, head to your kernel source directory and enter the configuration: cd /usr/src/linux ; make menuconfig
Once in, go to File systems > Network File Systems and enable “SMB file system support (to mount Windows shares etc.)” as a module. Exit the configuration tool, making sure to save the new config and run make: make ; make modules_install. Once finished, load the module into your kernel: modprobe smbfs.
At this point, you might want to hit up your routers admin panel to find the IP address for your NAS, unless you already know it. Inside the router, you should see a page called “DHCP Leases” which will list it:
With the IP address in hand, hit it up with your web browser and configure the NAS to your liking. You might want to name it something simple so that it will be easier to deal with. If you have a dual-hdd NAS and want the ultimate in security, you will want to choose RAID 1, which mirrors each one of the drives. JBOD is fine if you want a lot of storage, but it doesn’t make for a very secure “backup”, if one of the drives in the NAS fails.
If you haven’t run into problems yet, you should be good to run smbtree and find the network share you want to use. In my case, \TG_NAS is the NAS, while Volume_1 is the primary folder.
If for some reason you can’t use the smbtree, your desktop environment should have some easy way of accessing the list. In KDE for example, “Remote Places” can be found under the K Menu, beneath the System Menu sub-menu.
Windows shares use backslashes, but we will need to change those to normal slashes, and also the characters to small letters. So in the case of \TG_NAS, it becomes //tg_nas/. Now the only thing to do is create a mount folder and mount the share:
For the sake of simplicity, I created a folder under /mnt called nas, but you can name it to whatever you like. Mounting is simple: mount -t smbfs followed by an option switch and also the password if required: -o password=techgagerox. If your NAS doesn’t have a password, omit that part.
We already established that our network share was //tg_nas/ and the folder to access as Volume_1, so once done putting that all together, our share will be successfully mounted to /mnt/nas, as you can see in the photo. To see how much free space is available, you can do a df -BMB, also shown in the image.
To have the network drive mount with each boot, you can add an entry to your /etc/fstab. Here is a sample:
//tg_nas/Volume_1 /mnt/nas smbfs username=admin,password=techgagerox 0 0
From this point, your NAS is good to go. To back up, you can use any of the examples found thus far, or move onto the next page where we have some more elaborate examples.