About

  • Combination of the words "Andri" and "Droid"
  • Sysadmin, developer and a student
  • Born in Reykjavík, Iceland
  • Studying in Aalborg, Denmark
  • Not the Google project

Twitter

  • would you buy an ARM powered ultraportable for a extra few hours of battery?
  • Breaking: Broadcom open sources wireless drivers on Linux....
  • A really nice collection of web development resources....

Automatic USB backup with Ubuntu

Update: This article is originally from andri.dk and is provided as is. Some of the information is outdated, but hopefully still helpful to some.

Everyone has important files like personal photographs, bank statements, a life's accumulation of porn and so and and so forth that would be hard or impossible to recover if that damn hard drive would fail.

I've always been well aware of the dangers of not taking backups but yet still lazy enough to ignore it.

Backup for the lazy includes the following steps:

  • Put USB stick in computer
  • Wait for computer to BEEP or USB stick to stop flashing
  • Unplug USB stick
  • Rinse and repeat!

I wrote a package that does the following:

  • Detects USB drives connected to the computer and runs the backup script
  • Only runs backup on partitions that match the configured volume_id
  • Mounts the volume
  • Runs rsync and takes an incremental copy of the files that have changed since a last backup.
  • Unmounts the volume
  • Gives a good or a bad beep through the PC speaker

Step by Step

  1. Insert your USB stick/disk
  2. Make sure it has a usable partition. I use FAT32 so my Mac can also read it. (hint: System > Administration > Partition Editor)
  3. Download the two files and put them in the appropriate places
  4. Find the volume id of your partition and replace mine in the 'usb-backup' file
    root@ubahmaskine: vol_id -u /dev/sdd1
    4507-FB5A
  5. Set SRC_DIR to the directory you want backed up within 'usb-backup'
  6. Make sure the 'usb-backup' file has the execute permission for root:
    chmod 700 /usr/local/bin/usb-backup
  7. Unplug USB stick
  8. Plug in USB stick
  9. After it beeps or stops flashing try mounting it f.e.
    mount /dev/sdd1 /mnt/sdd1
  10. Check if all your files made it accross
  11. Unmount the volume again f.e.
    umount /dev/sdd1
  12. Unplug and plug it in again once a week or so.
  13. For audio beep to work you need the 'beep' package (apt-get install beep)

Notes and credit

  • Thanks to Anders for his original idea and implementation of this.
  • The script does not check if the volume has enough space to do the backup. If it doesn't, it will fail!
  • If umounting seems slow, it's due to delayed write to the USB drive.
  • Should work on other Linux distributions as long as udev is present.
  • This is provided 'as is' and offers no guarantee. Use at your own risk!

Comments

Hey, I would really love to

Hey, I would really love to use this, but the files to download were apparently never transfered over from andri.dk. Any way these files could be reposted?

Sorry mate, I've uploaded the

Sorry mate, I've uploaded the files now.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.