What's a good back-up strategy for 1 desktop PC?
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...
- 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!
- 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.
- 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.
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!
- Both USB Stick and..
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.
- Connect your backup drive (if not already connected) and mount it if it doesn't auto mount.
- 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) (seeman mount
for more information on 1 & 2) - Decide whether to use
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 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 sync
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