March 24, 2018

Linux Backups For Real People, Part 3 - page 3

Simple Network Backups

  • November 15, 2007
  • By Carla Schroder

An inexpensive way to perform network backups is to an external hard drive attached to one of your PCs. You'll need an SSH server running on its attached PC, and SSH clients for everyone else. Rather than giving everyone a login on the backup PC, create a special backup account for everyone to use with a clever, catchy name like "backup". Keep in mind that everyone who has access to the backup drive can easily read all the files on it.

Suppose the drive is attached to a PC named Penguina. Assuming you have local DNS like a good Linux geek, you can test logging in remotely like this:

$ ssh backup@penguina
backup@penguina's password:

You may also use the IP address, if it's a static address.

We don't want to be prompted for a password because that defeats automatic scheduled backups, so instead we'll use SSH public key authentication. It's easy to set up- just follow the "Public-Key Authentication" section of The (Practically) Ultimate OpenSSH/Keychain Howto, except do not set a passphrase!

Now let's fix up our backup script to use the remote drive. Change the last line to look like this:


Notice a new addition, the "carla" directory. Since this is a shared network drive you'll probably want to give each user their own directory. rsync will create them for you. Remember, do not have a trailing slash! (See Part 2 for more information.) The syntax is simple: login-name@hostname:/full-file-path-of-the-backup-directory.

Now what about scheduling unattended backups? Piece of cake--we'll make an entry in /etc/crontab, which is a delightfully simple way of using cron. This example runs the backup script every weeknight at 11:05pm:

23 5   * * 1-5   carla /home/carla/backupscript

man 5 crontab tells all of your options.

Most Popular LinuxPlanet Stories

Sitemap | Contact Us