November 10, 2023 01:27
Some operations will need a lot power or disk space, so consult
man borg for detailed information!
Make sure to have at least 1G+ free disk space for larger archives (bigger repository means more free space needed)!
To disable backup deletion see: ‘https://borgbackup.readthedocs.io/en/stable/usage/notes.html#append-only-mode'
You can add to nearly to any command:
-sShow statistics at finish
-pLittle information while working…
--dry-runWell, you know…
Legend for this
TARGETMeans the folders path (sometimes mentioned as repository) or an ssh-connection-folder (e.g.
NAMEMeans the archives name - maybe a
Create a borg folder/repository
borg init -e repokey TARGET
-e [MODE]Specifies the encryption; ‘keyfile’ is good (it will ask for the password every time) - you have the key under ~/.config/borg/keys/, ‘repokey’ is DANGEROUS WITHOUT PASSWORD (it will still ask for the password every time) - the key will be saved (with password encrypted) inside the repositories configuration, ’none’ is… yeah…
--append-onlyProhibits deletion of archives
--storage-quota [QUOTA]Set storage quota of the new repository (e.g. 5G, 1.5T) - useful to make sure to be able to delete afterwards…
Create an archive
borg create -C none TARGET::NAME [NOW MULTIPLE FOLDERS TO INCLUDE]
-C [MODE]Sets compression level;
zlibis medium speed and compression;
lzmais slow but best;
lzma,[COMPRESSIONLEVEL]are available too
--lock-wait [SECONDS]Maybe inside a script which fires multiple creations - to proccess the timeout on connection losses
borg check TARGET::NAMERechecks the archives integrity - useful to determine the size the dataloss after a drive failure
borg check --repair TARGET::NAMEONLY IF NECCESSARY… THIS WILL MINIMIZE DATA LOSS ON DAMAGED FILES BUT NOT FIX
borg list TARGETLists all available archives
borg info TARGET::NAMEArchive information…
borg prune TARGET::NAMERemoves archive
borg prune TARGET --keep-daily=7 --keep-weekly=4 --keep-monthly=6 --keep-yearly 2Cleans the repository up…
borg change-passphrase TARGETChanges keyfiles password
borg mount TARGET::NAME [DIR]Mounts the archive for easier operations…
borg umount [dir]Unmounts the archive…
borg key export TARGET [PATH]Backup the encryption key of the repository
borg key import TARGET [PATH]Restores the encryption key of the repository (useful with keyfile encrytion)
borg break-lock TARGETIn case borg cant finish the backup, you’ll need to release the lock manually
borg extract TARGET::NAME [PATH]Extracts the path from the archive to the current working directory
export BORG_PASSPHRASE='[PASSWORD]'Prevents the passwords request - BUT BE CAREFUL! THAT WILL BE SAVED E.G. TO THE BASH_HISTORY
export BORG_PASSCOMMAND='cat $HOME/.borg-passphrase'Same as above, but reads the password e.g. from a file (or e.g. from zenity –password). ‘~’ doesn’t work.
export BORG_KEY_FILE='[KEYFILE_PATH]'Specifies the path for the keyfile, if the key is stored locally (if not using the repokey)
export BORG_RSH='ssh -i [SSH_KEYFILE_PATH]'Maybe neccessary, if ssh fails to authenticate automatically with the keyfiles under ~/.ssh
Universal backup script
…was moved into an own repository -> see here.