65

No, this is not a comparison of back-up tools, nor is it a solicitation on What to backup or Why and only a little bit about Where to backup and When to do it.

This is basically a strategy question: what, where and when all together. "How" is not really relevant: there are tons of back-up programs out there and they all do the same basic thing: make copies of data.

But the real question is: are these back-up programs making copies of the data important to you? How should you install&run Ubuntu while safeguarding your data?

There is no "one size fits all" when it comes to computers, Ubuntu versions or a backup strategy, therefore I've split this up into 5 basic user types with each their own answer:

  1. I don't have a computer!
  2. My computer doesn't contain my life...
  3. My computer contains my life!
  4. My computer IS my life! (or you're running in UEFI mode!)

And as the above does not fit everyone, one for the impatient:

  1. I want the fastest possible Restore!

So click one of the above links and go to your user type!

P.S. If you're running a server farm and you've read this question so far, I'm sorry: this is about a single PC, not a network, nor a server farm.

6
  • 5
    This should be a community wiki, imo
    – Anwar
    Jul 2, 2015 at 7:26
  • 1
    You can make this as CW by consulting with a mod as far as i know
    – Anwar
    Jul 2, 2015 at 16:08
  • Should you address what not to back up? I asked the question here. I originally wrote the question thinking about files like desktop.ini - by itself it isn't a big deal size wise, but I wanted to look past that for any real optimization.
    – Ackis
    Aug 19, 2015 at 15:55
  • @Ackis: this is a strategy document, not a procedure: therefore it gives broad guidelines of what to back up, not any details. That is already answered elsewhere... ;-)
    – Fabby
    Aug 19, 2015 at 15:59
  • @fabby Well I didn't find the details on what to not backup elsewhere - hence my question submission a while ago. :P However in the strategy document should you mention that there are things you shouldn't backup?
    – Ackis
    Aug 20, 2015 at 13:53

6 Answers 6

30

1. I don't have a computer!

Indeed! The forgotten masses of Ubuntu! Well, not forgotten here... ;-)

The others might wonder, but you and I know: You might not have the big bucks to buy your own computer, but you've got your own personal computer safely tucked away on your USB stick/pen drive/SD Card/external HDD or even just simply your phone/tablet...

And you're safe, right? Backup??? You don't need one! It's all safely tucked away in your purse, in your drawer or in your pocket.

But what if you lose it? Or it gets stolen? Or you sit down comfortably and it slips out and you flush it and only realize it a split second after you've pushed the button...

  1. If you have a USB stick/pen drive/SD Card/external HDD ("USB stick" from now on) you're already saving up for a new one, right? Bigger!
  2. If you have a phone/tablet ("Phone" from now on) you're also saving up for a bigger/better version.

What to back up: Everything.

  1. USB stick: Save a little more. You have the MLC version already! Buy an SLC: they're 2-3 times more expensive for the same size then the MLC ones, but they're 4 to 8 times faster and they last much longer, so see it as an investment for the future.
  2. Phone: You have an MLC too don't you? Don't bother about an SLC: The newer phone you're saving for will use its internal memory to cache the bad performance of the MLC! Just don't buy the cheapest "Crap Inc. Hyper! Mega! Micro! SD! Card" but a good brand. With an SD-jacket so that when you do get your hands on a PC, it's easy to back up your phone. Ask about warranty.

    If you can't afford to back up everything, take the data that is irreplaceable: photos of your family, your current school/uni work, that stuff. And know that you shouldn't tinker too much getting your Ubuntu just right: it's expendable. That photo with that beautiful smile isn't.

Where to back up / Where to store it: Your old one!

  1. Both USB Stick and..
  2. Your Phone should be backed up to the old one. Don't worry that it's slow and outdated... It's something you can fall back on when something really nasty happens.

    And store it in a safe place: not in the same room and not in the same house if possible. (Brother/sister/cousin/niece around the corner is fine)

When to back up:

How much can you afford to lose? A week? A month? Do the data every week. (Please!) The system: every month.

8
  • 3
    "buy the cheapest "Crap Inc. Hyper! Mega! Micro! SD! Card" ha ha! I got a bunch of 2gb & 4gb microSD's years ago for $1-$1.50 each, they would corrupt fat32 in a few weeks, but ext3 is rock solid... go figure
    – Xen2050
    Jan 6, 2015 at 21:19
  • I had one yesterday: dd if=/dev/nul of=FirstHDD /Length=512 to overwrite the MBR if the MBR contains an ISO file system. Correct but without some serious warning extremely dangerous (and command obfuscated for obvious reasons)
    – Fabby
    Jan 7, 2015 at 7:26
  • 1
    You're trying to convince readers to backup, which is good, but don't expect that ones thinking of themselves as cases of section 2 will have enough patience to follow you through the end of at least section 3. It may sound awkward coming from me, but try to be more respectful. You want the reader to listen to you and show them where they can do better. Try to keep it short and only use formatting where necessary (too much bold and italics can be distracting). I would recommend a relative in another state instead of the neighbor for offsite backup and thinking about redundant backups. +1
    – LiveWireBT
    Jan 7, 2015 at 12:07
  • @LiveWireBT: Awkward? You? I'm always open to learn more... If you can improve it, just go ahead and edit! Ich habe kein Problem mit dem gründliches Gesichtspunkt... (Ich verstehe Deutsch, aber schreiben ist ziemlich schwierig)
    – Fabby
    Jan 7, 2015 at 12:38
  • 2
    I'm type 5. My backup is another system. Jan 17, 2015 at 22:56
23

4. My computer is my life!

The reason you bought the computer in the first place, is... Well, the computer! You tinker, you theme, you customise, you get it just right! But is it right for a back-up?
What if that last theme of yours stops you from logging into the desktop? Or that custom kernel you just downloaded freezes the entire system?

How to install Ubuntu:
Use 3 partitions at a minimum: swap, / and /home. You want to tinker that even further? Read the Filesystem Hierarchy Standard in it's entirety.

What to back up:
Everything! Your Phone! Your digital camera! Your tablet! The router settings! The TV firmware! The neighbour's tablet! The Psion! The Thermal Camera settings!
Back them all up on your computer! Forget about those clouds! The Internet will be down for 24 hours and you'll be needing all that data not to go into withdrawal!

Forget about swap! Never back up swap! It's just a raw partition anyway. Boot a CD and make an image or clone / excluding /home
There are lots of backup tools that support imaging and cloning out there. Always keep 2 images: the one you're making and the previous one. That way if the lightning hits the wire while you're doing your back-up, you'll still be able to restore the previous one!

Then just use some back-up program that looks cool and is fast and backup /home on the same hard drive on the same partition, in another directory unencrypted. (Google for "encrypted restore problem" if you want to know why)

Where to back up / Where to store it:
On an external USB HDD and in the cloud (after some serious public key encryption) Store the USB HDD somewhere safe not connected to the computer, but close by like in the next room so you can easily restore.

When to back up:
How much can you afford to loose? A day? A week??? Maybe just continuous back-up?

How to do a restore:
Boot the imaging/cloning CD, restore the image/clone (never use a clone!). After that, restore the differential back-up on /home

Done!

0
17

5. I want the fastest possible restore!

If speed of recovery and having everything exactly the way it was when you backed up is more important than the space the backup contains you can backup every drive using dd or dc3dd to create image file(s). Place the image file(s) on a drive that is large enough to contain everything. Note that you will need enough room to save EVERY sector of the drive(s) you are backing up, not just the space used. You can determine the full size of a drive and its devicename with the terminal command sudo fdisk -l or the Disks (Disk Utility) application.

When:

A. Whenever you've done more than you care to do over since the last backup
and / or
B. Prior to upgrading your system to a new version

Where:

External USB drive(s) or better: internal/external SATA/SCSI/Fibre Optic drives.

How:

All the commands used here (with the exception of mentioned applications like Disks, Disk Utility and Software & Updates) are entered from the command line via the Terminal. You can open a terminal from the GUI with CtrlAltT

Note: Backing up a mounted drive is never a good idea, so unmount your source drive first. I always accomplish image backups booted from live media so I don't have to worry about this and suggest you do the same. To be safe, double check the output of mount to make sure that your source drive isn't mounted.

  1. Connect your backup drive (if not already connected) and mount it if it doesn't auto mount.
  2. If it is already mounted, find out where it's mounted. The mount command or the Disks (Disk Utility) application can show you what drives are mounted and the paths they are mounted at. This will be where you store your disk image(s) (likely /media/"USB Volume Name" if you are backing up to an external USB drive) (see man mount for more information on 1 & 2)
  3. Decide whether to use dc3dd (or dd) and follow the set of instructions below that you have chosen.

Backup using dc3dd You can determine if dc3dd is installed with the command which dc3dd If installed it will return something like /usr/bin/dc3dd If you simply get the command prompt back it you can install dc3dd with the command sudo apt-get install dc3dd Note that this package is in the Universe repository and you will have to enable that repository in "Software & Updates" if it isn't already enabled prior to installation.

dc3dd if=/dev/sdy of=/target/mount/point/sdy.dd.img where sdy=your source drive (in a single drive system this will be sda)

A progress indicator will be provided that reports how much has been backed up and the speed of the process.

When the process is complete as evidenced by the progress indicator reaching 100% and the prompt returning it doesn't hurt to issue the command sync to ensure that the buffers are flushed to the output file. Now you can unmount (see man umount and disconnect the drive (if external) and put it some place safe.

Backup using dd

dd if=/dev/sdy of=/target/mount/point/sdy.dd.img where sdy=your source drive

no progress indicator will be shown although you can open another terminal window, find the dd process rapidly with top and issue the command kill -USR1 xxxx where xxxx is the process number for a one time status report.

You can skip this part unless you are interested ->dd Addendum regarding progress indicator:

In Ubuntu version 16.04 and beyond dd includes a progress indicator if you use the switch status=progress eliminating the need to use solutions like pv or the kill -USR1 approach mentioned above just to obtain progress. An example using the dd progress indicator is: dd if=/dev/sdy of=/target/mount/point/sdy.dd.img status=progress where sdy=your source drive (if you try this with a version that is too early to support it you'll just get an error that says dd: invalid status flag: ‘progress’

When the process is complete as evidenced by the prompt returning it doesn't hurt to issue the command sync to flush the buffers to the output file. Now you can unmount and disconnect the drive (provided it's external) and put it some place safe.

To restore:

Simply get your backup drive out of safekeeping, mount it, swap the if= and of= and use the same process.

Restore using dc3dd

dc3dd if=/target/mount/point/sdy.dd.img of=/dev/sdy where sdy=your target drive (in a single drive system this will be sda). When the process is complete as evidenced by the progress indicator reaching 100% and the prompt returning it doesn't hurt to issue the command sync to flush the buffers to the drive.

Restore using dd

dd if=/target/mount/point/sdy.dd.img of=/dev/sdy where sdy=your target drive (in a single drive system this will be sda). When the process is complete as evidenced by the prompt returning it doesn't hurt to issue the command syncto flush the buffers to the drive.

Now you can unmount and if you are using an external, disconnect and return the external drive to safekeeping.

Note: sync flushes the filesystem buffers (see man sync)

If any part of this answer is unclear, feel free to drop me a comment and I'll do my best to clarify further.

Source: 30+ years of experience

11
  • I agree, but that's more a comparison of back-up tools answer... This one is more about the strategy. And whether to use File or system back-ups (using images)
    – Fabby
    Feb 16, 2015 at 15:38
  • 1
    @Fabby I've seen that answer and I think this one is better suited here. It IS about strategy and I think the first sentence of my answer makes that clear. Also my answer works for ALL the user types you mention (provided of course storage space is available). Since the cost of storage per GB has dropped continuously over the past 30 years I think my approach is "future proof", cost effective, and fast. Of course since I lack the grandchildren, I had to take a more hands on approach. ;-)
    – Elder Geek
    Feb 16, 2015 at 16:47
  • 1
    @Fabby I've not seen a --sparse switch for dc3dd. There isn't much of a man page for it either although there is this:plus.google.com/+KarlBernard/posts/CFzGx6kNaHR I love ddrescue for it's ability to split and retry unreadable sectors as well as reading in reverse. It's great for data recovery but for simple imaging on undamaged hardware I've always used dc3dd (which makes it clear if the drive has problems by blasting retrying sector xxxxxxxxx in the output) in which case it's ddrescue to the rescue (or photorec). ;-) Edit looks good. Thanks!
    – Elder Geek
    Feb 16, 2015 at 20:46
  • 1
    @Fabby I'll be happy just to see them doing a backup at all!!!
    – Elder Geek
    Mar 15, 2015 at 14:17
  • 1
    @KostasMouratidis Since a mounted filesystem is subject to change at any point in time (unless of course it's mounted read-only) I would consider attempting that an exceedingly bad plan. Something will change between the time you start the backup and it's completion. As noted in my answer backing up while running off live media is a reliable approach.
    – Elder Geek
    Jun 24, 2019 at 10:49
7

3. My computer contains my life!

Everything you do, watch, pay, live! is on that thing...

What to back up:
Everything! Your Phone! Your digital camera! Your tablet! The kid's tablet! (Their level 70 wizard is screaming to be backed up! And if you don't: the kids will be crying their eyes out when that level 70 wizard gets corrupted! ) Back them all up on your computer! You don't know how? Ask a question at AskUbuntu or at android.stackexchange.com for those tablets and apple.stackexchange.com for the fruity-flavoured gizmos.

Your computer data: everything in /home! Ask a question at AskUbuntu specifying that you want the back-up program from the Live CD for easy restore.

Where to back up / Where to store it:
On an external USB HDD and use the Ubuntu standard back-up program. Type backup in the dash. Store the USB HDD somewhere safe away from the computer. Your husband's toolbox is probably the safest bet! It never gets used anyway!

When to back up:
How much can you afford to loose? A week? A month? Up to you! Just choose one and stick with it! If you really don't know: every week!

How to do a restore:
Boot the Ubuntu Live CD, re-install Ubuntu, do all the updates, then restore. You don't know how? Ask a question at AskUbuntu!

6

2. My computer doesn't contain my life!

You only use your computer to surf the web (Hah! That's backed up!), to e-mail (which is stored somewhere on them Interwebitubes), to Skype the kids, to watch some YouTube and that's it!

And you don't have a digital camera, right? And you never copy anything from that digital camera onto your computer (that's a back-up!) and then delete it from the camera (No, it's not a back-up if you only have one copy!)

And you don't have a phone, right? And you never copy anything from your phone onto your computer? And you've never dropped a phone in a bucket full of ice and water with a few floating beer bottles at the neighbour's, right?

And you've got print-outs of those electronic bills in your basement with a copy in your neighbour's, right?

Still all right on all of the above? Cool! You don't need to back up! Congratulations top 1%!
If not, continue below.

What to back up:
All them pesky gadgets you've got! Back them all up on your computer! You don't know how? Ask them pesky grandchildren of yours! They can and will do anything!
Tell them also to:

  1. make it fully automatic: connect the cable and you're good to go. OR
  2. not to touch the mouse nor the keyboard, but to be patient with you as you still want to be able to do it when they're gone! (Make notes!)

Your computer data: everything in /home! If the damn thing breaks down, call the grandkids and have them do a fresh install and then have them restore the data for you. You only need to know how to back up. The restore is their problem.

Where to back up / Where to store it:
Have the kids buy you one of those "external USB HDD"s and set it up for you. You should just connect it to the computer and everything should be running automatically. (I'm sure: just connect he cable and that's it! Leave it running overnight and then right-click that little Icon and choose "eject" and store it in the basement/attic/another room!)

When to back up:
Just before the Saturday night movie would be really nice! And especially just before those other grandchildren of yours show up! They can and will destroy anything!

2

Backing up all the programs would be 10 GB or more. It doesn't make much sense to back them up since they can be restored off the internet.

Backing up all your writings would be a couple MB. Unless you write very fast and frequently of course. Backing up your spreadsheets and presentations could be 100's of MBs if you have lots of clip art and images.

Backing up all your photos and songs could take dozens of GBs. An alternative would be to mirror the music and photos on your smartphone with Ubuntu. Chances are good a man made (fire, theft, vandalism, the ex) or Force Majeure (lightning, flood, earthquake) will not effect both devices at the same time.

Backing up your videos could be 100's of GBs.

You have to know what you have, where it is stored, how big it is and whether or not it needs to be backed up. You will have to think about this and do some research.


For myself I used an automated backup to compressed file (< 25 MB) every morning that is emailed to my gmail.com account. Each morning cron only backs up what I've written along with configuration files of Ubuntu settings.

After a year now I'll have to adopt a Father-Son-Grandfather backup strategy for Yearly, Monthly, Weekly and Daily backups to prune the number of backups (365+ days) currently stored in gmail.com which is limited to 15 GB for free to everyone on planet Earth (or theoretically Mars if they have an IP address).

If you are interested in my daily backup to gmail.com script, you can see it here: Backup Linux configuration, scripts and documents to Gmail.


You can buy cheap 16 GB, 32 GB or 64 GB USB flash drives (aka thumb drives) and copy your whole Ubuntu image and data files to it.

If you have a 500 GB hard drive or SSD and Ubuntu only takes up 25 to 50 GB you can create a backup partition to store backups. Note these will not be offsite backups nor will they save you if your hard drive crashes. These backup partitions are helpful when you shoot yourself in the foot and delete a whole bunch of files or directories. To clone your Ubuntu partition to another backup partition I wrote this script: Bash script to clone Ubuntu to new partition for testing 18.04 LTS upgrade

Additionally there are backup programs you can use but I can't vouch for them.

1
  • @Fabby Thanks for the edit. I got to research "Force Majeure". Interesting... Apr 28, 2019 at 15:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .