Advertisement

Advertisement

Site Search

Latest Forum Posts

Free Tech Mags

Backing Up Your Linux

Article Image
Print This ArticlePrint This Article
Date: August 27, 2007
Author(s): Rob Williams

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.

Backup To External Storage

On this page, we will be tackling the absolute basics of mounting your external storage device. This could be a flash-based thumb drive or external hard-drive, such as one in an enclosure. If you know the basics of mounting your hardware, then you can bypass this section entirely.

Depending on your external storage's filesystem, you will need to make sure that the support is built into the kernel. Chances are very good that there is but if not, you will need to go into your kernel configuration and add it.

You likely already have Ext2 and Ext3, but if not you can enable them to be built into the kernel. If you lack VFAT support, which would be unbelievable, you can add it under File systems > DOS/FAT/NT Filesystems > VFAT (Windows-95) fs support. Once done, exit and run make ; make modules_install. At that point, you should reboot and let the new modules take effect, or copy the kernel and boot into it, if you compiled a different kernel version from the one you are currently using. If you compiled the FS as modules, simply modprobe them.

While most distros auto-mount thumb drives and the like, I dislike that method when working with backups. If you have an external hard drive that is -always- plugged in, it's fine, but if you remove it often, drive letters can change and render your script useless. This is all moot if you plan to manually type the rsync command each time you want to back up.

If your distro picks up on the drive and you'd rather it not, then simply unmount it and do your own thing. -If- the distro mounts the drive to the exact same point each time (eg: /media/disk1) then you shouldn't have to worry about much. It's only when device points change that it will become a problem (eg: /media/sda1 /media/sdb1 /media/sdc1 etc).

Figuring out drive letters can be fun if you've never done it before. Technically, each IDE device counts as one, and same with each S-ATA device. That said, if you have two IDE CD-Roms and two S-ATA hard-drives, the devices would be:

  • /dev/hda
  • /dev/hdb
  • /dev/sda
  • /dev/sdb

If you plug in an external drive with two partitions, it would be:

  • /dev/sdc1
  • /dev/sdc2

Any new external device will be /dev/sd* more than likely, so if you had four devices as shown in the top example, a thumb drive would assume the place of /dev/sdc, as the direct example above shows. Let's assume that your external hard-drive has a FAT32 and NTFS partition.

techgage@localhost ~ $ su
Password:
localhost techgage # mkdir /mnt/thumb
localhost techgage # mount -t vfat /dev/sdc1 /mnt/thumb

Most external hard-drives will be FAT, although high-density drives might use NTFS if it's store-bought. External hard-drives can be ext3 as well, but that's up to you. If you are unsure what type of partition a drive is, you can simply fdisk /dev/sdc and hit p and note the partition id code. Hit l (small L) to view the known partition types and match the code. In FAT32's case, the code is b, while NTFS is 7. Process to mount is all similar though, more often than not.

techgage@localhost ~ $ su
Password:
localhost techgage # mkdir /mnt/ntfs
localhost techgage # mount -t ntfs /dev/sdc2 /mnt/ntfs

You can add lines to your fstab if the drive is permanent.

/dev/sdc1 /mnt/thumb vfat defaults 0 0
/dev/sdc2 /mnt/ntfs ntfs defaults 0 0

With your drive mounted, you are now able to back up like a pro. Next up, setting up your NAS.


<< Back Forward >>