Poor Man’s Local Backup

backup-local | backup | backup-rsync | backup-upload | encryption

warning

beware of symlinks — the target folders defined in backup.lst must not be symlinks (parent folder being a symlink is ok)

requirements

debian/ubuntu

apt install ksh lftp

# (optional) in case you want GnuTLS instead of OpenSSL
apt purge gnupg2 gnupg
apt install gnupg1

slackware

slackpkg search ksh93
slackpkg search lftp

netbsd

(PDKSH built-in)
pkg_info | grep lftp

Setup

keep a copy of the key some place outside the server you wanna backup

mkdir -p /data/backup/
vi /etc/backup.conf
backupdir=/data/backup
maxold=5
secret="SYMMETRIC-KEY-HERE"

# rsync, ftp or none
method=none

#uploaddir=/data/backup

# Dedibackup FTP
#server=FTP-SERVER
#user=auto
#pass=""

# rsync through ssh
#rsyncdest=SSH-SERVER:/path/to
chmod 600 /etc/backup.conf

define the folders you wanna backup

vi /etc/backup.lst

/etc
/root
/var

chmod 600 /root/backup.lst

acceptance 1 - backup

attempt a manual backup first

# https://pub.nethence.com/bin/backup/backup.ksh.txt
time nice /root/backup.ksh

eventually check that this is multi-core capable (>100%)

top -b | grep ssl
top -b | grep gpg

check for the resulting files

ls -lhF /data/backup/

acceptance 2 - restore

attempt to restore from an encrypted archive

cd /data/backup/
# https://pub.nethence.com/bin/backup/backup-decrypt.ksh.txt
time nice /root/backup-decrypt.ksh 2024-01-21-07-49-35.etc.tar.lz4.camellia

and eventually check the content of every archive sample, just to make sure you truly got the folder content, in case it’s a symlink

ready to go

finally enable the job every night as a priviledged cron job as follows

netbsd

vi /etc/daily

slackware

vi /root/DAILY

time nice /root/backup.ksh
#time nice /root/backup-upload.ksh

debian/ubuntu

crontab -e

00 04 * * * time nice /root/backup.ksh
#00 04 * * * time nice /root/backup.ksh; time nice /root/backup-upload.ksh

resources

lftp

lftp user credentials do not work with -e or -c https://unix.stackexchange.com/questions/469787/lftp-user-credentials-do-not-work-with-e-or-c

Mirror copying hidden (dot) files regardless. #251 https://github.com/lavv17/lftp/issues/251 –> or consider yafc instead?

lz4

How to use tar with lz4? https://stackoverflow.com/questions/24063846/how-to-use-tar-with-lz4


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun