https://youtu.be/W_l82GF00UY?t=1120
https://blog.unixhost.pro/2023/01/borg-backup-detailed-guide/
https://docs.borgbase.com/restore/borg/cli
AmazonLinux 2023 install borg
yum -y install python3-devel libacl-devel
pip3 install -U pip
pip3 install borgbackup
Borg Client
set borg IP /etc/hosts
cat > .ssh/config <<EOF
Host *
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
GlobalKnownHostsFile /dev/null
EOF
# /root/.ssh/authorized_keys auto login
echo "c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUg4WkI1bUtyMG5VNW11MHdFbkdhaFA3Yjk3aTg1eUV1aUZiYmtJVndXbHQgcm9vdEBpcC0xNzItMzEtMzEtMjA2LnNhLWVhc3QtMS5jb21wdXRlLmludGVybmFsCg==" | base64 -d >> /root/.ssh/authorized_keys
# /root/.ssh/id_ed25519
echo "LS0tLS1CRUdJTiBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLS0KYjNCbGJuTnphQzFyWlhrdGRqRUFBQUFBQkc1dmJtVUFBQUFFYm05dVpRQUFBQUFBQUFBQkFBQUFNd0FBQUF0emMyZ3RaVwpReU5UVXhPUUFBQUNCL0dRZVppcTlKMU9acnRNQkp4bW9UKzIvZTR2T2NoTG9oVzI1Q0ZjRnBiUUFBQUxndlZjWVdMMVhHCkZnQUFBQXR6YzJndFpXUXlOVFV4T1FBQUFDQi9HUWVaaXE5SjFPWnJ0TUJKeG1vVCsyL2U0dk9jaExvaFcyNUNGY0ZwYlEKQUFBRUFuNmhsclZWd1drWktBZ3JNY2JUekQ4Qjg1V3lSenE1Q1VvSUhYUTI5U29uOFpCNW1LcjBuVTVtdTB3RW5HYWhQNwpiOTdpODV5RXVpRmJia0lWd1dsdEFBQUFNSEp2YjNSQWFYQXRNVGN5TFRNeExUTXhMVEl3Tmk1ellTMWxZWE4wTFRFdVkyCjl0Y0hWMFpTNXBiblJsY201aGJBRUNBd1FGCi0tLS0tRU5EIE9QRU5TU0ggUFJJVkFURSBLRVktLS0tLQo=" | base64 -d > /root/.ssh/id_ed25519
chmod 400 /root/.ssh/id_ed25519
# /root/.ssh/id_ed25519.pub
echo "c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUg4WkI1bUtyMG5VNW11MHdFbkdhaFA3Yjk3aTg1eUV1aUZiYmtJVndXbHQgcm9vdEBpcC0xNzItMzEtMzEtMjA2LnNhLWVhc3QtMS5jb21wdXRlLmludGVybmFsCg==" | base64 -d > /root/.ssh/id_ed25519.pub
Borg Server
/usr/sbin/useradd -m borg
mkdir /opt/borg
chown borg:borg /opt/borg
/usr/sbin/usermod -d /opt/borg borg
echo -e "root\nroot" | passwd borg
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
systemctl restart sshd
# /home/borg
[ ! -d /home/borg/.ssh ] && mkdir /home/borg/.ssh
echo "c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUg4WkI1bUtyMG5VNW11MHdFbkdhaFA3Yjk3aTg1eUV1aUZiYmtJVndXbHQgcm9vdEBpcC0xNzItMzEtMzEtMjA2LnNhLWVhc3QtMS5jb21wdXRlLmludGVybmFsCg==" | base64 -d >> /home/borg/.ssh/authorized_keys
# /opt/borg
[ ! -d /opt/borg/.ssh ] && mkdir /opt/borg/.ssh
echo "c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUg4WkI1bUtyMG5VNW11MHdFbkdhaFA3Yjk3aTg1eUV1aUZiYmtJVndXbHQgcm9vdEBpcC0xNzItMzEtMzEtMjA2LnNhLWVhc3QtMS5jb21wdXRlLmludGVybmFsCg==" | base64 -d >> /opt/borg/.ssh/authorized_keys
Dummy test
mkdir test
dd if=/dev/random of=./test/file1 bs=1MB count=1000
dd if=/dev/random of=./test/file2 bs=1MB count=1000
dd if=/dev/random of=./test/file3 bs=1MB count=1000
cp ./test/file1 ./test/file1-1
cp ./test/file1 ./test/file1-2
cp ./test/file1 ./test/file1-3
du -sh test/*
954M test/file1
954M test/file1-1
954M test/file1-2
954M test/file2
954M test/file3
borg init -e none borg@borg:bkp
borg create --list -C zstd borg@borg:bkp::test ./test/
borg info borg@borg:bkp
Remote: Warning: Permanently added 'borg' (ED25519) to the list of known hosts.
Repository ID: c49970e31c69db8bc424b0beeeded6f76bda4ac5ff8565fb7f3a098f64aa265d
Location: ssh://borg@borg/./bkp
Encrypted: No
Cache: /root/.cache/borg/c49970e31c69db8bc424b0beeeded6f76bda4ac5ff8565fb7f3a098f64aa265d
Security dir: /root/.config/borg/security/c49970e31c69db8bc424b0beeeded6f76bda4ac5ff8565fb7f3a098f64aa265d
------------------------------------------------------------------------------
Original size Compressed size Deduplicated size
All archives: 5.00 GB 5.00 GB 3.00 GB
Unique chunks Total chunks
Chunk index: 1112 1842
borg create --list -C zstd borg@borg:bkp::test2 ./test/
Remote: Warning: Permanently added 'borg' (ED25519) to the list of known hosts.
Repository ID: c49970e31c69db8bc424b0beeeded6f76bda4ac5ff8565fb7f3a098f64aa265d
Location: ssh://borg@borg/./bkp
Encrypted: No
Cache: /root/.cache/borg/c49970e31c69db8bc424b0beeeded6f76bda4ac5ff8565fb7f3a098f64aa265d
Security dir: /root/.config/borg/security/c49970e31c69db8bc424b0beeeded6f76bda4ac5ff8565fb7f3a098f64aa265d
------------------------------------------------------------------------------
Original size Compressed size Deduplicated size
All archives: 10.00 GB 10.00 GB 3.00 GB
Unique chunks Total chunks
Chunk index: 1113 3684
in borg server
[borg@ip-172-31-18-20 ~]$ du -sh bkp
2.8G bkp