Borg backup verification

You need SSH access to @rsync.net to run all the commands

In every command replace replace <repo> with the location of the repository

Currently available repositories:

  • borg/linode/gitlab
  • borg/linode/gsc
  • borg/linode/elearning
  • borg/linode/sgsi
  • borg/linode/secwall
  • borg/linode/webapps

Check integrity

Repository integrity

To verify the integrity of the repository run the following command

borg check --verbose zh1637@zh1637.rsync.net:<repo> --archives-only

Example:

borg check --verbose zh1637@zh1637.rsync.net:borg/linode/gitlab --repository-only

Remote: Starting repository check
Remote: Starting repository index check
Remote: Index object count match.
Remote: Completed repository check, no problems found.

Archives integrity

To verify the integrity of all the archives run the following command

borg check --verbose zh1637@zh1637.rsync.net:<repo> --repository-only

Example:

borg check --verbose zh1637@zh1637.rsync.net:borg/linode/gitlab

Remote: Starting repository check
Remote: Starting repository index check
Remote: Index object count match.
Remote: Completed repository check, no problems found.
Starting archive consistency check...
Enter passphrase for key ssh://zh1637@zh1637.rsync.net/./borg/linode/gitlab:
Analyzing archive gitlab-2021-07-20T23:24:19.103582 (1/14)
Analyzing archive gitlab-2021-07-21T11:15:12.431350 (2/14)
Analyzing archive gitlab-2021-07-22T02:00:21.247166 (3/14)
Analyzing archive gitlab-2021-07-23T02:00:20.363842 (4/14)
Analyzing archive gitlab-2021-07-24T02:00:19.547897 (5/14)
Analyzing archive gitlab-2021-07-25T02:00:20.729888 (6/14)
Analyzing archive gitlab-2021-07-26T02:00:18.393876 (7/14)
Analyzing archive gitlab-2021-07-27T02:00:17.846869 (8/14)
Analyzing archive gitlab-2021-07-28T02:00:19.149677 (9/14)
Analyzing archive gitlab-2021-07-29T02:00:19.671252 (10/14)
Analyzing archive gitlab-2021-07-30T02:00:19.645896 (11/14)
Analyzing archive gitlab-2021-07-31T02:00:17.254910 (12/14)
Analyzing archive gitlab-2021-08-01T02:00:20.572721 (13/14)
Analyzing archive gitlab-2021-08-02T02:00:18.308202 (14/14)
Archive consistency check complete, no problems found.

List archives and files

List archives

To list all the current archives run the following command

borg list zh1637@zh1637.rsync.net:<repo>

To view only the N last archives user de --last N option

Example to list the last 2 archives:

borg list zh1637@zh1637.rsync.net:borg/linode/gitlab --last 2

gitlab-2021-08-01T02:00:20.572721    Sun, 2021-08-01 02:00:36 [cb76db54750de5cad7aaf6dee3335d4f8c3ec122e8b850d7c265d084cf0d01d2]
gitlab-2021-08-02T02:00:18.308202    Mon, 2021-08-02 02:00:31 [47c7b57af2a656d60a057b1707ec66ef23b71c75eecc85735ca4fae075d9f0e3]

List files in archives

The way borg works, the most recent archive is always the most complete, even if it didn't backup any file. When you list the files in the archives it always show all the file that represente the current state of the folders that where in the backup To list what really was backup in an archive, use de diff command, check examples.

To list all files in an archive run the following command

borg list  zh1637@zh1637.rsync.net:<repo>::<archive_name>

Example:

borg list zh1637@zh1637.rsync.net:borg/linode/gitlab::gitlab-2021-08-02T02:00:18.308202

➜  ~ borg list zh1637@zh1637.rsync.net:borg/linode/gitlab::gitlab-2021-08-02T02:00:18.308202
Enter passphrase for key ssh://zh1637@zh1637.rsync.net/./borg/linode/gitlab:
drwxrwxr-x git    root          0 Mon, 2021-08-02 01:32:42 backups/gitlab
-rw-r--r-- git    git    16517120 Mon, 2021-07-26 09:08:22 backups/gitlab/1627286902_2021_07_26_14.0.5_gitlab_backup.tar
-rw-r--r-- git    git    683929600 Sun, 2021-08-01 01:31:15 backups/gitlab/1627777873_2021_08_01_14.1.0_gitlab_backup.tar
-rw-r--r-- git    git    683663360 Thu, 2021-07-29 01:31:23 backups/gitlab/1627518680_2021_07_29_14.1.0_gitlab_backup.tar
-rw-r--r-- git    git    683530240 Tue, 2021-07-27 01:31:20 backups/gitlab/1627345878_2021_07_27_14.1.0_gitlab_backup.tar
-rw-r--r-- git    git    683929600 Sat, 2021-07-31 01:31:21 backups/gitlab/1627691478_2021_07_31_14.1.0_gitlab_backup.tar
-rw-r--r-- git    git    683581440 Wed, 2021-07-28 01:31:15 backups/gitlab/1627432273_2021_07_28_14.1.0_gitlab_backup.tar
-rw-r--r-- git    git    683816960 Fri, 2021-07-30 01:31:15 backups/gitlab/1627605073_2021_07_30_14.1.0_gitlab_backup.tar
-rw-r--r-- git    git    768819200 Mon, 2021-08-02 01:32:42 backups/gitlab/1627864359_2021_08_02_14.1.0_gitlab_backup.tar
drwxr-xr-x root   root          0 Mon, 2021-07-26 09:12:40 etc
drwxr-xr-x root   root          0 Wed, 2020-05-27 22:43:52 etc/groff
-rw-r--r-- root   root       1048 Sat, 2020-03-21 12:27:30 etc/groff/man.local
-rw-r--r-- root   root       1042 Sat, 2020-03-21 12:27:30 etc/groff/mdoc.local
drwxr-xr-x root   root          0 Wed, 2021-06-09 14:28:03 etc/grub.d
-rwxr-xr-x root   root      17622 Mon, 2020-08-17 15:04:31 etc/grub.d/10_linux
...

Diff between archives

To check was really was backup in an archive use the diff command

borg list  zh1637@zh1637.rsync.net:<repo>::<previous_archive_name> <current_archive_name>

Example - List files backup between the archives of 2021-08-01 and 2021-08-02

borg diff zh1637@zh1637.rsync.net:borg/linode/gitlab::gitlab-2021-08-01T02:00:20.572721 gitlab-2021-08-02T02:00:18.308202

added     768.82 MB backups/gitlab/1627864359_2021_08_02_14.1.0_gitlab_backup.tar
removed   683.37 MB backups/gitlab/1627173080_2021_07_25_14.0.5_gitlab_backup.tar
removed   683.37 MB backups/gitlab/1627259484_2021_07_26_14.0.5_gitlab_backup.tar

Extract files (for restore)

To extract files use the extract command

If <file_path> is not defined, all the archive will be estracted.

borg extract  zh1637@zh1637.rsync.net:<repo>::archive_name> <file_path>

Example:

borg extract --list zh1637@zh1637.rsync.net:borg/linode/gitlab::gitlab-2021-08-01T02:00:20.572721 backups/gitlab/1627864359_2021_08_02_14.1.0_gitlab_backup.tar

backups/gitlab/1627864359_2021_08_02_14.1.0_gitlab_backup.tar

Files are extracted to the current folder, the original structure is re-created.

Found errors? Think you can improve this documentation? Simply click the Edit link at the top of the page, and then the icon on Github to make your changes.