+4 votes
64 views
in Linux Create by (242k points)
reopened
Linux backup - that's how it works

1 Answer

+5 votes
by (1.6m points)
 
Best answer

What should be secured?
Create the conditions
Create backups with Back In Time
1st step:
2nd step:
3rd step:
4th step:
5th step:
6th step:
Restore files
More functions

You should back up important files regularly. You can read here how this works under Linux - step by step..

image image

File losses are the exception today, but as annoying as ever. We'll show you how to back up important photos, your work, configurations and so on under Linux - in the style of Apple's Time Machine.

What should be secured?

First of all, you need to identify the folders and files that you want to be backed up in the first place. Which files you put where is of course up to you. By default, however, there are two main locations that you should back up: Your personal files are in your home folder, i.e. under "/ home / USERNAME /" - including your desktop, downloads, pictures and so on. Many configurations are located in the "/ etc" folder, which is also worth backing up accordingly.

You can also save a list of all installed programs. If your current system should actually fail, you can not only restore your data on a new system, but also all previously installed programs.

And there are things that you should explicitly not back up: Temporary files, possibly the Downloads folder, the recycle bin, working copies and integrated network folders.

In addition, backups should run automatically, outdated backups should be automatically deleted and it should be possible to restore individual file versions. All of this works wonderfully with the "Back In Time" tool, which is intended for Gnome and KDE, so it fits wonderfully into Ubuntu, for example. Of course, it also works fine with Xfce and other desktops. The whole thing then resembles Apple's Time Machine..

image

Create the conditions

You need two things: "Back In Time" and a place to store the backups. The installation of Back In Time is super easy and works according to the standard pattern in the terminal with " sudo apt-get install backintime-qt4 ".

You can use an existing second hard drive, mount a USB data carrier or use a network share as the storage location. Network shares are now a separate topic again, but in a nutshell: In a typical network with Samba shares, for example on a NAS, you can integrate folders via the "/ etc / fstab" file.

Assuming you want to include the "Backup_HDD" folder shared on the NAS on your local Ubuntu in your user folder as the "Backup_HDD" folder,then proceed as follows:

  1. Install support for the cifs filesystem: " sudo apt-get install cifs-utils ".
  2. In " / etc / fstab " add a - customized! - Line like: " //192.168.178.100/Backup_HDD / home / USERNAME / Backup_HDD cifs defaults, uid = 1000, username = MY USERNAME, password = MY PASSWORD ".
  3. Mount the share with " sudo mount -a ".

The NAS folder is now available to you under "/ home / USERNAME / Backup_HDD" like a normal local folder in which to store the backups. The fstab line is basically very simple: First comes the shared folder, then the mount point, then the file system (cifs), then the cifs standard options (defaults), the authorized user (user ID 1000 is the current standard users) as well as the login data for the NAS.

If you want to create a list of the installed apps, you can do that with "dpkg --get-selections | awk '{print $ 1}'> ~ / mypackagelist". (Installing the programs on the list then works later with "xargs -a" mypackage list "sudo apt-get install".)

Create backups with Back In Time

You can find the installed Back In Time via the start menu - in two versions: standard and as a root version. If you want to back up system files, for example the "/ etc" folder, start the root version.

Back In Time starts directly with the configuration. Create backup jobs using a total of six tabs, here as one step each:

1st step:

image
Under " General " you first define the storage location , for example the network share you just created or another folder. You also set the " Schedule ": Perhaps the best option is " Repetitive (anacron) ". As with the other options, you can have daily, weekly or monthly backups made here. The special thing about it: Normally the " cron "Such tasks - but only when the computer is running. Anacron stands for" anachronistic cron "and basically only means that the tasks are carried out if the computer was switched off at the time of the planned execution.

2nd step:

image
In the " Include " tab, add the files and folders you want to back up.

3rd step:

image
It continues with " Exclude ": You should keep the given patterns for files not to be backed up. And very important: Add any existing network shares such as the backup folder " Backup_HDD " yourself. After all, the backup is intended to protect local files and not remote devices.

4th step:

image
You can basically leave the " Remove automatically " tab as it is - if you want to keep all snapshots (backups) forever. If not, you should activate intelligent deletion here and define how many snapshots should be kept and which ones should be deleted.

5th step:

image
In the " Options " section, it might make sense for laptop users to deactivate the backup during battery operation. Also relevant: You can determine whether files replace any newer versions of themselves when you restore them or whether both variants are retained. The other options are not important at the beginning.

6th step:

image
In the " Settings for experts ", there is initially only one option that is relevant to getting started: By default, Back In Time saves symbolic links from the source system as links - so that the linked files themselves are not saved. If you also want to back up the files behind links, activate " Copy links (trace symbolic links) " accordingly .
Finally confirm the configuration with " OK ". You land in the main interface of Back In Time, the "main profile" you just created is active, as you can see in the top left of the window. Now take a first snapshot to test the configuration.

Restore files

On the left of the window you can see the snapshots you have made. If you select one of them, you will see the saved folder structure including all files on the right in the window. Individual files, folders or entire backups can now be restored with a right-click.

image

More functions

Of course, you can do even more with Back In Time, for example create an additional profile for a complete system backup - the configuration even offers an automatic mechanism for this: Simply create a new profile and click the "Change for complete system backup" button. Then set the schedule and the full backup is ready..

Under the surface, Back In Time happily uses standard tools such as cron, anacron and above all rsync for the actual copying processes. And in the "Settings for experts" you can also set further rsync options manually. With this wonderful backup tool you get a beginner-friendly, simple graphical user interface, but also access to the full power (and reliability) of rsync.


...