Hermes – Borg backup

You are here:Home-Resources-Hermes-Hermes – Borg backup
Hermes – Borg backup 2018-04-16T14:42:52+00:00

This is a simple tutorial how to use borg backup

Step 1: Initialise a folder as backup destination (/home/chenglim/borg)

chenglim@ansible:~$ borg init --encryption=repokey /home/chenglim/borg
Enter new passphrase:
Enter same passphrase again:
Do you want your passphrase to be displayed for verification? [yN]: N

By default repositories initialized with this version will produce security
errors if written to with an older version (up to and including Borg 1.0.8).

If you want to use these older versions, you can disable the check by runnning:
borg upgrade --disable-tam '/home/chenglim/borg'

See https://borgbackup.readthedocs.io/en/stable/changes.html#pre-1-0-9-manifest-spoofing-vulnerability for details about the security implications.
chenglim@ansible:~$

Step 2: Create first backup source from /home/chenglim/pybot/ to destination /home/chenglim/borg

chenglim@ansible:~$  borg create /home/chenglim/borg::backup1 ~/pybot/
Enter passphrase for key /home/chenglim/borg:
chenglim@ansible:~$

Step 3: Adding a dummy file and run second backup

chenglim@ansible:~$ touch ~/pybot/testme.txt
chenglim@ansible:~$ borg create /home/chenglim/borg::backup2 ~/pybot/
Enter passphrase for key /home/chenglim/borg:
chenglim@ansible:~$

Step 4: Verify both backup

chenglim@ansible:~$ borg list /home/chenglim/borg
Enter passphrase for key /home/chenglim/borg:
backup1                              Mon, 2018-04-16 13:37:09
backup2                              Mon, 2018-04-16 13:37:38
chenglim@ansible:~$

Step 5: List all the files in backup 1

chenglim@ansible:~$ borg list /home/chenglim/borg::backup1
Enter passphrase for key /home/chenglim/borg:
drwxrwxr-x chenglim chenglim        0 Mon, 2018-04-16 12:39:15 home/chenglim/pybot
-rw-rw-r-- chenglim chenglim        0 Mon, 2018-03-12 15:47:53 home/chenglim/pybot/README.md
-rw-rw-r-- chenglim chenglim        0 Mon, 2018-03-19 12:07:25 home/chenglim/pybot/chatbot.out
lrwxrwxrwx chenglim chenglim        0 Tue, 2018-04-10 09:16:21 home/chenglim/pybot/chatbot.py -> nsccbot.py
-rw-r--r-- chenglim chenglim      410 Tue, 2018-04-10 09:23:46 home/chenglim/pybot/chatbot.service
-rw-rw-r-- chenglim chenglim     1784 Tue, 2018-04-10 09:07:56 home/chenglim/pybot/echobot.py
-rw------- chenglim chenglim        0 Mon, 2018-04-16 12:17:21 home/chenglim/pybot/nohup.out
-rw-rw-r-- chenglim chenglim     2593 Mon, 2018-04-16 12:10:55 home/chenglim/pybot/nsccbot.py
-rw-rw-r-- chenglim chenglim      824 Mon, 2018-03-19 16:40:24 home/chenglim/pybot/qna.py
chenglim@ansible:~$

Step 6: List all file in “backup2” and verify indeed a new file is created called “testme.txt”

chenglim@ansible:~$ borg list /home/chenglim/borg::backup2
Enter passphrase for key /home/chenglim/borg:
drwxrwxr-x chenglim chenglim        0 Mon, 2018-04-16 13:37:26 home/chenglim/pybot
-rw-rw-r-- chenglim chenglim        0 Mon, 2018-03-12 15:47:53 home/chenglim/pybot/README.md
-rw-rw-r-- chenglim chenglim        0 Mon, 2018-03-19 12:07:25 home/chenglim/pybot/chatbot.out
lrwxrwxrwx chenglim chenglim        0 Tue, 2018-04-10 09:16:21 home/chenglim/pybot/chatbot.py -> nsccbot.py
-rw-r--r-- chenglim chenglim      410 Tue, 2018-04-10 09:23:46 home/chenglim/pybot/chatbot.service
-rw-rw-r-- chenglim chenglim     1784 Tue, 2018-04-10 09:07:56 home/chenglim/pybot/echobot.py
-rw------- chenglim chenglim        0 Mon, 2018-04-16 12:17:21 home/chenglim/pybot/nohup.out
-rw-rw-r-- chenglim chenglim     2593 Mon, 2018-04-16 12:10:55 home/chenglim/pybot/nsccbot.py
-rw-rw-r-- chenglim chenglim      824 Mon, 2018-03-19 16:40:24 home/chenglim/pybot/qna.py
-rw-rw-r-- chenglim chenglim        0 Mon, 2018-04-16 13:37:26 home/chenglim/pybot/testme.txt
chenglim@ansible:~$

Step 7: Extract the file to current directory

<pre class="theme:github lang:default decode:true">chenglim@ansible:~$ ls
borg  cloudmonkey  logs  pybot  terraform
chenglim@ansible:~$ borg extract /home/chenglim/borg::backup2
Enter passphrase for key /home/chenglim/borg:
chenglim@ansible:~$ ls
borg  cloudmonkey  home  logs  pybot  terraform
chenglim@ansible:~$ ls -l ~/home/chenglim/pybot/
total 16
-rw-rw-r-- 1 chenglim chenglim    0 Mar 19 12:07 chatbot.out
lrwxrwxrwx 1 chenglim chenglim   10 Apr 10 09:16 chatbot.py -&gt; nsccbot.py
-rw-r--r-- 1 chenglim chenglim  410 Apr 10 09:23 chatbot.service
-rw-rw-r-- 1 chenglim chenglim 1784 Apr 10 09:07 echobot.py
-rw------- 1 chenglim chenglim    0 Apr 16 12:17 nohup.out
-rw-rw-r-- 1 chenglim chenglim 2593 Apr 16 12:10 nsccbot.py
-rw-rw-r-- 1 chenglim chenglim  824 Mar 19 16:40 qna.py
-rw-rw-r-- 1 chenglim chenglim    0 Mar 12 15:47 README.md
-rw-rw-r-- 1 chenglim chenglim    0 Apr 16 13:37 testme.txt
chenglim@ansible:~$

Step 8: Delete one of the borg backup

chenglim@ansible:~$ borg list /home/chenglim/borg
Enter passphrase for key /home/chenglim/borg:
backup1                              Mon, 2018-04-16 13:37:09
backup2                              Mon, 2018-04-16 13:37:38
chenglim@ansible:~$ borg delete /home/chenglim/borg::backup1
Enter passphrase for key /home/chenglim/borg:
chenglim@ansible:~$ borg list /home/chenglim/borg
Enter passphrase for key /home/chenglim/borg:
backup2                              Mon, 2018-04-16 13:37:38
chenglim@ansible:~$ borg delete /home/chenglim/borg::backup2
Enter passphrase for key /home/chenglim/borg:
chenglim@ansible:~$ borg list /home/chenglim/borg
Enter passphrase for key /home/chenglim/borg:
chenglim@ansible:~$

 

Ref:

http://borgbackup.readthedocs.io/en/stable/quickstart.html