Backups take some planning and there are several viable strategies. You will have to decide which method works best for you.

Be careful about "best way" , what works best for one person may not be best for another.

At the end of the day, the "best method" is one that has been tested and known to work. You need to test your backup strategy BEFORE you need it

Using images

One way is to simply copy and compress an image of your partitions. You can do this with several tools, anything from dd to partimage to clonezilla

partimage

clonezilla

The advantage of this strategy is that it is (relatively) easy and very complete. The disadvantage is that the back up images are large.

Smaller backups

You can make smaller backups by only backing up data and settings. There are several tools to do this, everything from dd to tar to rsync.

The key here is to know what you need to back up.

Advantage - Backups will be smaller.

Disadvantage - This is a manual method, so it is easy to forget about a critical file (/etc/passwd).

A list of what to back will always need to be reviewed to make sure the list is complete.

1) List of installed packages

Package list # Create a text list of an existing installation of all apt-get installed packages # in order to re-install on a newly installed distro

# make the list [old distro] sudo dpkg --get-selections > packages

You would then perform a fresh install, and restore your packages. The following commands also update all the packages on your system (so restore and full update all at once).

# Now put them back on the new distro [new distro] sudo dpkg --set-selections < packages [new distro] sudo apt-get dselect-upgrade

2) Data. Generally this would be /home . Most user data and customization's are going to be in your users home directory. If you save data in other locations, include that (for example /media/data).

3) system settings . Here is where there is going to be some variation. Personally if I edit ANY system setting, I keep a copy of the original configuration file and my custom file in /root. So if I edit /etc/fstab for example, keep a copy in /root/etc/fstab and original in /root/etc/fstab.orig

You will also need /etc/passwd , /etc/shadow , /etc/group , /etc/sudoers , /etc/hostname , and /etc/hosts (you may need more in /etc, if I forgot something I will add it)

On a server you may need to include /var/www or other data directories.

I understand this takes some effort, so, it may be easier to include all of /etc .

4) A copy of your disk partition table.

sudo fdisk -l > fdisk.bak

You can use this information to restore your partition table if you replace your hard drive.

5) A copy of your MBR

sudo dd if=/dev/sda of=MBR.bak bs=512 count=1

You would then restore with

sudo dd if=MBR.bak of=/dev/sda bs=512 count=1

6) Other files/directories - Depending on your system and customization you may need to include additional directories. Considerations might include /opt , /usr/local , /usr/share`, and/or your .desktop files. Anything on your system you downloaded or customized outside of apt-get or software manager.

7) Put all that into an archive

sudo tar -cvpzf backup.tar.gz /home /root /etc ./MBR.bak ./fsdisk.bak ./packages

8) rsync

As an alternate to tar, you can use rsync.

See - https://help.ubuntu.com/community/rsync

Network backups

Another option is to use NFS or Samba to back up data.

Cron

You can automate backups by writing a backup script and running it (daily / hourly) with cron.

Restore

1) Using a live CD, restore your partitions using gparted or fdisk from the information in fdisk.bak

2) Install Ubuntu.

3) Boot your new install, update your packages.

4) Restore your data and settings

tar -xvpzf /home/test/backup.tar.gz -C /

Then reboot

See also - https://help.ubuntu.com/community/BackupYourSystem/TAR

Other Strategies

There are many additional strategies for backup, some for backing up your home directory only, some graphical.

see: https://help.ubuntu.com/community/BackupYourSystem

Testing

It is not a backup unless it is tested. This is most important when you are NOT using an image of your root partition.

Test restoring your system in a VM, a spare computer, or a spare partition or hard drive.