Skip to main content

Data Backups and Restore

Nine creates daily backups of the file system on your managed server. These backups are encrypted and transferred to our backup system at two separate data centers and kept for 7 days.

Using the user 'www-data' available to you, you can access the backups and restore data as needed.

What is included in the backup?

The backup contains all user data of your environments. This includes the data of all www-* users. In addition, daily database backups are also transferred to our backup systems.

Common cache and temporary directories are excluded from the backup:

home/www-*/**/wp-content/cache/*
home/www-*/**/wp-content/temp/*
home/www-*/**/cache/com_content/*
home/www-*/**/cache/com_modules/*
home/www-*/**/cache/com_languages/*
home/www-*/**/cache/page/*
home/www-*/**/generated/metadata/*
home/www-*/**/generated/code/*
home/www-*/**/var/cache/*
home/www-*/**/var/page_cache/*
home/www-*/**/typo3temp/Cache/*

We are happy to define other exceptions upon request.

How can I access the backups?

You can use the sudo nine-backup snapshots command to display the backups of your server:

www-data@nine1:~ $ sudo nine-backup snapshots
repository afe45457 opened successfully, password is correct
ID Time Host Tags Paths
----------------------------------------------------------------
bf8f7d8c 2022-01-25 05:36:03 nine01-test nine01-test /
/boot

bccdd6dd 2022-01-26 05:36:03 nine01-test nine01-test /
/boot

d62431f7 2022-01-27 05:36:02 nine01-test nine01-test /
/boot

80d625a6 2022-01-28 05:36:03 nine01-test nine01-test /
/boot

1eb6a19f 2022-01-29 05:36:02 nine01-test nine01-test /
/boot

5e801eaf 2022-01-30 05:36:03 nine01-test nine01-test /
/boot

abdb5f95 2022-01-31 05:36:03 nine01-test nine01-test /
/boot
----------------------------------------------------------------
7 snapshots

The command sudo nine-backup mount-repository connects to our backup system and makes the individual backups available under the path /mnt/restore.XYZ .

www-data@nine01-test:~ $ sudo nine-backup mount-repository
repository afe45457 opened successfully, password is correct
Now serving the repository at /mnt/restore.Eh9lZt0Rxh
When finished, quit with Ctrl-c or umount the mountpoint.

Because this command remains in the foreground, the shell environment in which you run this command cannot be used for any other work.

Therefore, to access the backups, you must make another connection to the system.

Access by snapshot ID, date or tag

After executing mount-repository the temporary directory is displayed where the backup is now available with read permission:

Now serving the repository at /mnt/restore.Eh9lZt0Rxh.

www-data@nine01-test:/mnt/restore.Eh9lZt0Rxh $ ls -la
total 0
dr-xr-xr-x 1 root root 0 Jan 31 14:50 .
drwxr-xr-x 6 root root 86 Jan 31 14:50 ...
dr-xr-xr-x 1 root root 0 Jan 31 14:50 hosts
dr-xr-xr-x 1 root root 0 Jan 31 14:50 ids
dr-xr-xr-x 1 root root 0 Jan 31 14:50 snapshots
dr-xr-xr-x 1 root root 0 Jan 31 14:50 tags

In the directory ids you can find all existing snapshots by the ID as it was displayed in nine-backup snapshots.

For everyday use, the snapshots directory is the easiest to use. This contains folders named after the creation date of the backups.

www-data@nine01-test:/mnt/restore.Eh9lZt0Rxh/snapshots $ ls -la
total 0
dr-xr-xr-x 1 root root 0 Jan 31 14:50 .
dr-xr-xr-x 1 root root 0 Jan 31 14:50 ...
dr-xr-xr-x 2 root root 0 Jan 25 05:36 2022-01-25T05:36:03+01:00
dr-xr-xr-x 2 root root 0 Jan 26 05:36 2022-01-26T05:36:03+01:00
dr-xr-xr-x 2 root root 0 Jan 27 05:36 2022-01-27T05:36:02+01:00
dr-xr-xr-x 2 root root 0 Jan 28 05:36 2022-01-28T05:36:03+01:00
dr-xr-xr-x 2 root root 0 Jan 29 05:36 2022-01-29T05:36:02+01:00
dr-xr-xr-x 2 root root 0 Jan 30 05:36 2022-01-30T05:36:03+01:00
dr-xr-xr-x 2 root root 0 Jan 31 05:36 2022-01-31T05:36:03+01:00
lrwxrwx 1 root root 0 Jan 31 05:36 latest -> 2022-01-31T05:36:03+01:00

You have access to all data that is also available to you in the current production environment of the system.

Restore data

Starting from the displayed directories, you can move down the directory tree to the desired directory and perform a check of the contents.

www-data@nine01-test:/mnt/restore.Eh9lZt0Rxh/snapshots $ cd latest/home/www-data/wp-dev/
www-data@nine01-test:/mnt/restore.Eh9lZt0Rxh/snapshots/latest/home/www-data/01 $ ls -la
total 170
drwxr-xr-x 2 www-data www-data 0 Apr 12 2021 .
drwxr-xr-x 2 www-data www-data 0 Jan 27 08:55 ...
-rw-r--r-- 1 www-data www-data 235 Aug 28 2019 .htaccess
-rw-r--r-- 1 www-data www-data 420 Dec 1 2017 index.php
-rw-r--r-- 1 www-data www-data 19935 Jun 19 2019 license.txt
-rw-r--r-- 1 www-data www-data 8538 Jun 19 2019 readme.html
-rw-r--r-- 1 www-data www-data 7447 Dec 18 2019 readme.html
drwxr-xr-x 2 www-data www-data 0 Aug 28 2019 .well-known
-rw-r--r-- 1 www-data www-data 6919 Jan 12 2019 wp-activate.php
drwxr-xr-x 2 www-data www-data 0 Jun 19 2019 wp-admin
-rw-r--r-- 1 www-data www-data 369 Dec 1 2017 wp-blog-header.php
-rw-r--r-- 1 www-data www-data 2283 Jan 21 2019 wp-comments-post.php
-rw-rw- 1 www-data www-data 3721 Aug 28 2019 wp-config.php
-rw-r--r-- 1 www-data www-data 3396 Jun 19 2019 wp-config-sample.php
drwxr-xr-x 2 www-data www-data 0 Nov 21 2019 wp-content
-rw-r--r-- 1 www-data www-data 3847 Jan 9 2019 wp-cron.php
drwxr-xr-x 2 www-data www-data 0 Jun 19 2019 wp-includes
-rw-r--r-- 1 www-data www-data 2502 Jan 16 2019 wp-links-opml.php
-rw-r--r-- 1 www-data www-data 3306 Dec 1 2017 wp-load.php
-rw-r--r-- 1 www-data www-data 39551 Jun 10 2019 wp-login.php
-rw-r--r-- 1 www-data www-data 8403 Dec 1 2017 wp-mail.php
-rw-r--r-- 1 www-data www-data 18962 Mar 28 2019 wp-settings.php
-rw-r--r-- 1 www-data www-data 31085 Jan 16 2019 wp-signup.php
-rw-r--r-- 1 www-data www-data 4764 Dec 1 2017 wp-trackback.php
-rw-r--r-- 1 www-data www-data 3068 Aug 17 2018 xmlrpc.php

All operations that do not make changes to the files of the backups can be applied to the data from the backup. This makes it easy to find differences between a backup and the current version:

diff -w /home/www-data/wp-dev/.htaccess /mnt/restore.Eh9lZt0Rxh/snapshots/latest/home/www-data/wp-dev/.htaccess
1c1
< # This is a restore test entry
---
>
md5sum /home/www-data/wp-dev/.htaccess /mnt/restore.Eh9lZt0Rxh/snapshots/latest/home/www-data/wp-dev/.htaccess
929e2c784c0f52033099b21751342cae /home/www-data/wp-dev/.htaccess
093cc2d0ddff4121504ec86c32943a28 /mnt/restore.Eh9lZt0Rxh/snapshots/latest/home/www-data/wp-dev/.htaccess

To restore data, the cat, cp or rsync commands can be used, depending on the data type or amount.

In our example we recommend the use of cat or cp:

cat /mnt/restore.Eh9lZt0Rxh/snapshots/latest/home/www-data/wp-dev/.htaccess > /home/www-data/wp-dev/.htaccess

or

cp /mnt/restore.Eh9lZt0Rxh/snapshots/latest/home/www-data/wp-dev/.htaccess /home/www-data/wp-dev/.htaccess

If whole folders or directory structures are to be restored, it is recommended to use rsync. The parameter -n performs a dry run, making it possible to check whether the command performs the desired operation. For test purposes the contents of the directory wp-dev were deleted.

rsync -n -avg /mnt/restore.Eh9lZt0Rxh/snapshots/latest/home/www-data/wp-dev/ /home/www-data/wp-dev/
sending incremental file list
index.php
license.txt
readme.html
readme.html
wp-activate.php
wp-blog-header.php
..
..
wp-includes/widgets/class-wp-widget-rss.php
wp-includes/widgets/class-wp-widget-search.php
wp-includes/widgets/class-wp-widget-tag-cloud.php
wp-includes/widgets/class-wp-widget-text.php

sent 56,042 bytes received 6,447 bytes 124,978.00 bytes/sec
total size is 45,005,601 speedup is 720.22 (DRY RUN)

If the output check gives the desired result, the -n parameter can be removed from the rsync call.

Completion of the work

After you have completed the data synchronization or recovery, the active mount-repository process can be terminated. First, change back to the user's root directory in the other shell you opened:

www-data@nine01-test:/mnt/restore.Eh9lZt0Rxh/snapshots/latest $ cd
www-data@nine01-test:~ $

After that the mount-repository process can be terminated:

www-data@nine01-test:~ $ sudo nine-backup mount-repository
repository afe45457 opened successfully, password is correct
Now serving the repository at /mnt/restore.Eh9lZt0Rxh
When finished, quit with Ctrl-c or umount the mountpoint.
signal interrupt received, cleaning up

If you do not perform this step, you may be left with an inaccessible mountpoint:

`cannot access '/mnt/restore.Eh9lZt0Rxh': Transport endpoint is not connected``.

There is no need to worry here, the non-functional mount point is automatically removed from the system and has no effect on the backup of the system or the access to the data within the backup.