Built-in back up system on Ubuntu

7,418

Solution 1

I'm listing this as an answer because I've spent years coming up with a solution that I believe should be considered for most users who really want a backup strategy they can depend on.

[Some may fairly argue my response does not directly answer the question asked as far as HowTo with the built-in backup. I just was hoping to help anyone searching backups for Ubuntu here. I do not expect this to be the selected answer. I've gone around-the-wheel with rsync, deja dupe, duplicati, bacula, flyback, timevault and many more. They all have strengths and weaknesses.]

Monthly: CloneZilla Image

You can add a line to your Grub menu to boot from a local CloneZilla ISO and then send the backups to a storage medium of choice (options like AWS S3, NFS server, tethered/attached drive). I reboot and hit the Grub choice and go to bed on the 1st of the month. You could even automate this more if you like, but this works great for me.

Daily: Borg Backup

I have this run 3 times a day on a systemd timer, at about 6-hour intervals ... 6 AM, Noon, 6 PM. Again you have flexibility on where to store the backups. I prune and keep the last 14 days and one from each month for 3 years. It deduplicates so the sizes are remarkably small.

Restoring with CloneZilla is a full image, very easy. Borg Backup has great documentation and you can extract to a temporary folder and do as you must.

Last, I do this on a 2 drive dual boot system. It allows me to be "reckless" at times and try things I never would have, knowing I can revert the system to 6 hours ago.

Example of my Grub entry for CloneZilla ... it even works on Wifi with a little effort! In brief it connects to my wireless network and uses an NFS mount point on a server.

menuentry "Clonezilla Auto" {
loopback loop (hd0,1)$isofile
linux (loop)/live/vmlinuz boot=live union=overlay username=user hostname=nuc2 \
    config NOSWAP edd=on nomodeset locales="en_US.UTF-8" keyboard-layouts="en" \
    components quiet nodmraid toram=filesystem.squashfs nosplash findiso=${isofile} \
    ocs_prerun=\"sudo service network-manager start \" \
    ocs_prerun1=\"sudo sleep 1 \" \
    ocs_prerun2=\"nmcli radio \" \
    ocs_prerun3=\"sudo sleep 10 \" \
    ocs_prerun4=\"sudo nmcli device wifi connect SOMENETWORK5G password someP@$$Word3# \" \
    ocs_prerun5=\"dhclient -v wlp1s0 \" \
    ocs_prerun6=\"iwconfig  wlp1s0 power off \" \
    ocs_prerun7=\"mount -t nfs4 192.168.1.2:/partimag/nuc2 /home/partimag -o noatime,nodiratime,rsize=32768,wsize=32768 \" \
    ocs_live_run=\"ocs-sr -q2 -j2 -z1p -i 0 -fsck-src-part-y -sc -p true savedisk autoname all \" \
    ocs_postrun=\"ls -dt /home/partimag/*/ \| tail -n +7 \| xargs rm -rf\" \
    ocs_postrun1=\"sudo sleep 5 \&\& sudo poweroff \" \
    ocs_live_batch=\"no\" 
initrd (loop)/live/initrd.img
}

Solution 2

Since you now use the default Déjà Dup app, you would need to reinstall Ubuntu, reattach the external HDD, then launch Déjà Dup and restore from within it.

Déjà Dup is a GUI for Duplicity. The encrypted tar files which Déjà Dup makes to back up the /home directory contents can be manually opened, and specific files extracted to selectively restore specific files and directories at any time.

The earlier answer is much more comprehensive, and discusses why to choose what to use and how to use it. Learning what's out there and making an informed decision about how to protect your data is extremely useful. I would not be happy with just one backup in an drive stored in the same place as the computer, as that's won't protect against file, flood, quake, or theft.

Share:
7,418

Related videos on Youtube

Mark
Author by

Mark

Updated on September 18, 2022

Comments

  • Mark
    Mark over 1 year

    Screenshot showing backup appI now use an external 2 TB HDD to store backups in case of a system crash. If Ubuntu fails to boot for any reason, how do I use the external HDD to recover the system to its full glory with all the docs, pictures, music, videos, and other files?

    Do I need to boot it from the boot menu for recovery?

    • guiverc
      guiverc over 4 years
      It depends how you backup your files. Myself I use rsync, and would just install a new Ubuntu system on a replacement hdd/box, then rsync my files to this system from my backup drive. I personally don't bother with system state (within an hour I'd have new system installed & setup pretty close to how I'd like it, my data files restored etc). What backup tool are you using? What release of Ubuntu?
    • Mark
      Mark over 4 years
      Ubuntu 18.04. Speaking of backup tool I'm using the default backup tool Ubuntu is being shipped with. It doesn't give me any option as to what mode to use for backups. See screenshot.
    • guiverc
      guiverc over 4 years
      The tool you are using is Déjà Dup and there is nothing wrong with it, it's just not what I use; wait for advice from someone who's familiar with the tool (rsync is also installed by default; however rsync is a command line tool rather than gui tool)
    • Mark
      Mark over 4 years
      So my understanding is that this tool doesn't back up the system as a whole but only the home directory containing all the docs. Meaning if the system crushes I have to install Ubuntu from the scratch and then run the tool to retrieve all my docs.
  • Mark
    Mark over 4 years
    Hmm ... does it mean that the built-in backup tool on Ubuntu is useless ?
  • Mark
    Mark over 4 years
    By no means useless, but I wanted something that imo I considered bullet-proof. I've been doing this for a very long time and the mix of full image snapshot (CloneZilla) and intraday differentials (Borg) have saved me more times than I can count. You have to find what works for you between a balance of effort and reliability. Many folks will rightly assert that you just need to back up your Home directory and can always reinstall Ubuntu. For me, I have so many years of customization that doesn't hold true.
  • Mark
    Mark over 4 years
    I'm gonna tick it as you're suggesting a solution that has worked for you in the long-term.
  • Mark
    Mark over 4 years
    That's king of you, but if you have a change of mind I fully understand. You are likely to get a number of very valid answers directly to your question that are a better-suited response to the question you have asked.
  • Mark
    Mark over 4 years
    I understand that the answer above is a great solution if you want to back up the system as a whole. Not just the home directory. It clones the whole os. Including all system files. It's great 'coz it also saves system settings so when you recover the whole system, you don't need to do all the customization like you need to do after fresh Ubuntu install.