Using Borg to backup data
In this example we use:
- Borg over SSH to set up remote repo.
- SSH keys to login.
Install
Install Borg on Debian and Ubuntu based Linux.
sudo apt install borgbackup
Install Borg on other Systems.
Go to https://www.borgbackup.org/releases/
Set up remote repo.
1. Initialize a repository on remote host.
borg init -e repokey user118@65.21.93.164:/home/user118/repo
2. Backup the ~/disks
and ~/folder
directories into an archive called first
.
borg create -v --stats user118@65.21.93.164:/home/user118/repo::first ~/disks ~/folder
3. List all archives in the repository.
borg list user118@65.21.93.164:/home/user118/repo
4. List contents of archive named third
.
borg list user118@65.21.93.164:/home/user118/repo::third
5. Restore the third
archive to current directory.
borg extract user118@65.21.93.164:/home/user118/repo::third
6. Delete the third
archive.
borg delete user118@65.21.93.164:/home/user118/repo::third
Note that this does not free repo disk space.
7. Recover disk space by compacting the segment files in the repo.
ssh user118@65.21.93.164 borg compact /home/user118/repo
8. Delete the whole repository and the related local cache:
borg delete user118@65.21.93.164:/home/user118/repo
9. SSHFS
If it is not possible to install Borg on the remote host, it is still possible to use the remote host to store a repository by mounting the remote filesystem, for example, using sshfs:
This will mount remote directory disks
to local directory extra
.
sshfs user118@65.21.93.164:/home/user118/disks ~/extra
borg init -e repokey ~/extra/repo
fusermount -u /home/{user}/extra