How to back up my entire system?
FILES
Refer to this howto: http://ubuntuforums.org/showthread.php?t=35087
In simple terms, the backup command is:
sudo tar czf /backup.tar.gz\
--exclude=/backup.tar.gz\
--exclude=/dev\
--exclude=/mnt\
--exclude=/proc\
--exclude=/sys\
--exclude=/tmp\
--exclude=/lost+found\
/
Add more --exclude=
parameters if you need to.
It will create an archive of all your files at /backup.tar.gz
, which should be copied to another computer or drive.
To restore your files when the system goes pear-shaped, use a Live CD. Mount the bad system under /media
or /mnt
and then run tar xf /path/to/drive/with/backup.tar.gz -C /mnt
(or /media
).
GRUB
This will not cover GRUB, however you can easily reinstall it by following this guide here. You only need to do steps Three and Four.
Noone noticed clonezilla. It makes a complete image of your hard drive, so it backups absolutely everything. It's as easy as burning an iso or creating a bootable flash drive.
The actual backup takes a while, but is the most reliable.
To clone your system to another system. Or make a backup. In terminal type:
dpkg --get-selections | grep -v deinstall > ubuntu-files
This command makes a file list of all installed packages in your system (and stores it in present working directory). Backup this file in hdd, email, etc...(this file is very small).
In the freshly installed ubuntu system run:
sudo dpkg --set-selections <./ubuntu-files (will set it up and)
apt-get -y update
apt-get dselect-upgrade
This will install only those packages you had installed (with apt-get
) in the old system.
(OR)
You could back up all the .deb
packages from /var/cache/apt/archives/
and install them manually using:
dpkg -i *.deb
And after that running an update cycle later.
Here is a solution I use with SquashFS. It is quite similar to TAR.GZ solution proposed earlier, but has some major benefits.
SquashFS is a compressed file system, which is completely stored in one file. This file can be mounted to an existing system and accessed in a usual way, like any other partition. The difference to TAR.GZ is that SquashFS is a full-blown file system with random access to files, while TAR is just one big concatenated file.
This means that if you want to mount some large backup of your whole file system, for TAR.GZ it would take like 5 hours (in my experience) and for SquashFS it would take just minutes/seconds. The same is true also for the compression/backup operation, SquashFS is many times faster.
UPDATE 2017-01-31: It appears that not only can you mount squashfs file, but also open it as a usual archive with familiar apps like File Roller on Linux and 7-Zip on Windows, etc.
So here is a command I use to back up my root folder:
sudo mksquashfs / /path/to/backup/hdd/root-backup.sqsh -e home media dev run mnt proc sys tmp
where "-e" switch excludes folders you want to exclude (like virtual and external Linux folders in my example).
After the backup is done, I can now mount it:
sudo mkdir /mnt/root_backup
sudo mount /path/to/backup/hdd/root-backup.sqsh /mnt/root_backup -t squashfs -o loop
Now just wait couple minutes (depending on size of the archive) and enjoy all your files at /mnt/root_backup folder.
Same can be done for /home/myname folder, e.g.
sudo mksquashfs /home/myname /path/to/backup/hdd/home-backup.sqsh -e Dropbox GoogleDrive
I exclude Dropbox and GoogleDrive here to avoid any potential problems in the future, in case I restore those folders from backup and they become messing with the actual files in the cloud.
Check more info at http://tldp.org/HOWTO/SquashFS-HOWTO/creatingandusing.html