Creating a simple, quick Borg backup

Here is how to create a simple borg backup. Something more along the lines of a zip file than a careful backup system. I’m using this method for long term storage. The primary benefits are de-duplication and compression.

Again, to clarify – these are not backups meant to be updated each day/week/month. These are simply long term storage that I normally would have made by rsyncing or making a tgz.

To create, run the following (see below for encrypted backup option):

# create an empty archive called test1
borg init -e none test1 

# add files to the archive
borg create test1::first /path/to/files

# verify/check the archive
borg info test1

My test case gave 50% savings:

                       Original size      Compressed size    Deduplicated size
All archives:               50.42 GB             35.15 GB             25.58 GB

                       Unique chunks         Total chunks
Chunk index:                  215930               520240

Don’t forget that you can mount borg archives to browse files.

borg mount test1::first /mnt/borg
borg unmount /mnt/borg

Test restore on another host:

# bundle up the directory
tar czpvf test1.borg.tgz test1

On another host:

# retrieve from original host
wget http://yourdomain.com/test1.borg.tgz

# unpack the archive
tar xzpvf test1.borg.tgz

# check/verify the archive
/usr/local/sbin/borg info test1
Warning: Attempting to access a previously unknown unencrypted repository!
Do you want to continue? [yN] y

# create a directory to restore to
mkdir restore

# mount the archive
borg mount test1 restore/

# work with the files in the archive
# ls restore

# umount the archive
borg umount restore

# extract all files from the archive
# first, list the snapshots
borg list test1

# extract a snapshot
cd restore/
borg extract ../test1::first 

Creating an encrypted backup

Adding encryption is easy :

# create an empty, encrypted archive called test1
# enter the passphrase when prompted
borg init -encryption=repokey test1 

# export the key
borg key export test1 test1.key

# create the archive
# enter passphrase when prompted
borg create test1::first /path/to/files

History:

2020/11/18 at 3:56 pm

Leave a comment

Your email address will not be published. Required fields are marked *