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:
- I don't have a computer!
- My computer doesn't contain my life...
- My computer contains my life!
- My computer IS my life! (or you're running in UEFI mode!)
And as the above does not fit everyone, one for the impatient:
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.
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...
What to back up: Everything.
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!
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.
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!
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 commandsudo 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.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) (seeman mount
for more information on 1 & 2)dc3dd
(ordd
) 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 commandsudo 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 (seeman 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 driveno 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 likepv
or thekill -USR1
approach mentioned above just to obtain progress. An example using thedd
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 saysdd: 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 commandsync
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 commandsync
to 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
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:
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!
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!
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.