8

I was doing some reading about how to backup and I kept running across people who say to just backup the /home/ folder instead of the whole system. I just don't understand the thinking here because what about all the programs one has installed?

Surely if you lose your system, you would want a quick way to restore all of your data instead of having to go through and re-install all the missing programs as you slowly find you need them on your new system, right?

Daniel
  • 3,446
Joff
  • 504
  • 2
  • 6
  • 15
  • Generally you can install most / all of your programs from the command line - it then becomes trivial to write a small script to install the required programs... – Charles Green Sep 30 '15 at 23:53
  • I agree with what Daniel has to say. /home contains all of your data, including a few programs. Like he says, it also has your app settings inside, so reinstalling your apps requires no configuration whatsoever. And, like he says, backing up the whole system will take a while and then restoring it will also take a while; you might as well to a drive clone. /home is already large enough without having apps, system files and logs to copy as well. – TheWanderer Oct 01 '15 at 01:13
  • but what about installled things that store data like postgres sql databases, and other things that will not be stored in the home folder – Joff Oct 01 '15 at 01:28

3 Answers3

4

I'd also say a backup of the whole system is not necessary. /home and maybe /etc should be enough. And if you also backup the package-selection you are up and running quite fast after a disaster.

For Back In Time I wrote a user-callback script which will place all necessary infos in your home before creating a new snapshot. Install Back In Time from Software Centre and configure it to backup /home/<YOUR_USER>. If you want to backup /etc configure an other Back In Time profile with Back In Time (root) because only root has full access to /etc. Than copy the script below to ~/.config/backintime/user-callback and make it executable with chmod 755 ~/.config/backintime/user-callback

#!/bin/sh
#    Copyright (c) 2012-2014 Germar Reitze
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License along
#    with this program; if not, write to the Free Software Foundation, Inc.,
#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

# backup selection of apt-get
# Take a look at 
# https://github.com/bit-team/backintime/wiki/FAQ#how-to-backup-debian-ubuntu-package-selection
# https://github.com/bit-team/backintime/wiki/FAQ#how-to-restore-debian-ubuntu-package-selection

profile_id="$1"
profile_name="$2"
reason="$3"
errorcode="$4"
DST="$HOME/.apt-backup"

case $reason in
    1) #on process begin
       mkdir -p $DST
       dpkg --get-selections > $DST/package.list
       apt-mark showauto > $DST/pkg_auto.list
       apt-mark showmanual > $DST/pkg_manual.list
       rm -f $DST/sources.list.d/*
       cp -aR /etc/apt/sources.list* $DST/
       apt-key exportall > $DST/repo.keys
       ;;
esac

After a disaster you need to follow these steps:

  1. install Debian/Ubuntu on your new hard drive as usual
  2. install backintime-qt4 from our PPA

    sudo add-apt-repository ppa:bit-team/stable
    sudo apt-get update
    sudo apt-get install backintime-qt4
    
  3. connect your external drive with the snapshots

  4. start Back In Time. It will ask you if you want to restore your config. Sure you want! Back In Time should find your snapshots automatically. Just select the one from which you want to restore the config and click Ok.
  5. restore your home
  6. recreate your /etc/apt/sources.list if you had something special in there. If your Debian/Ubuntu version changed don't just copy them from ~/.apt-backup/sources.list
  7. copy your repositories with

    sudo cp ~/.apt-backup/sources.list.d/* /etc/apt/sources.list.d/
    
  8. restore apt-keys for your PPA's with

    sudo apt-key add ~/.apt-backup/repo.keys
    
  9. install and update dselect with

    sudo apt-get install dselect
    sudo dselect update install
    
  10. make some "housecleaning" in ~/.apt-backup/package.list. For example you don't want to install the old kernel again. So run

    sed -e "/^linux-\(image\|headers\)/d" -i ~/.apt-backup/package.list
    
  11. install your old packages again with

    sudo apt-get update 
    sudo dpkg --set-selections < ~/.apt-backup/package.list 
    sudo apt-get dselect-upgrade
    
  12. restore package selection with

    sudo apt-mark auto $(cat ~/.apt-backup/pkg_auto.list)
    sudo apt-mark manual $(cat ~/.apt-backup/pkg_manual.list)
    

I'm member of BIT Dev-Team

Germar
  • 6,377
  • 2
  • 26
  • 39
1

You can back up your whole system, but it's more complicated to restore, and also takes FOREVER! If I were you I would just back up /home/ and reinstall apps if you need to. When you back up /home/ you also back up app preferences, so you won't lose your settings.

Daniel
  • 3,446
1

If you want to backup the entire system, it is best to do it cold by booting into something like clonezilla. Then you image the whole drive as a snapshot. You can later restore by booting into clonezilla again or similar and copying the disk image back over the disk.

http://clonezilla.org/

If you want to backup a database, such as postgres as you mention, you should use database tools particular to your setup. For example, I use AutoMySQLBackup to backup my MySQL database with rolling backups. I put the command in a crontab that checks if my USB drive is connected and, if so, runs the backup.

http://sourceforge.net/projects/automysqlbackup/

Thirdly, if it's your personal machine, you should also be backing up /home. For this, I use "Back in Time" which keeps track of changes in files. This protects you even from problems like overwriting or deleting a file by mistake, undoing edits and other user errors. Lifehacker has a good overview of it. It's also a good idea to occasionally make a full copy of your /home to a USB drive and store it off-site such as at your office. You can use an encrypted USB drive if that's a concern.

http://lifehacker.com/5212899/back-in-time-does-full-linux-backups-in-one-click

Many people find the full disk clone/restore isn't really less hassle than just doing a fresh install. Many people also don't have their own SQL databases. That's why you see the focus on just /home.