4.6 KiB
backup-scripts
This repository includes a series of scripts to setup and maintain borg repositories, both encrypted and unencrypted.
Assumptions
For remote repositories, this script assumes that you already have users, ssh keys, services, storage, and access permissions already configured. It is recommended that a remote borg repository has it's own user associated with it on the remote machine as a security precaution. That user should be the owner of all directories where the actual repository is to be stored.
If you have questions, you can see the borg documentation.
Disclaimer
Before running any software on your machine, it is good practice to read through it and have at least a general understanding of what it does. I'm just someone on the internet, writing software. It may have bugs. It may make assumptions about your system. It may need modification. This is backup software. It's important you understand what it's doing with your data. Don't trust a single thing I say here, read the software. Code speaks for itself.
This software is distributed WITHOUT ANY EXPRESS OR IMPLIED WARRANTY. If I'm feeling generous, and haven't grown tired of maintaining this software, I MAY make changes. If you have any questions, read the LICENSE file.
AI Disclaimer
All code in this repository was written by a human, however it was passed through a review process using Google Gemini. My time is precious. Troubleshooting with the help of an AI greatly speeds up the process. This is not "vibe coded", however, it was "spellchecked" with the use of an AI. If this bothers you, don't run this software. It's as simple as that.
The AI helps fix my mistakes, but it does not write my code. It offers suggestions, and I use my best judgement to decide whether or not I want to include them. Sometimes I allow it to annotate my code with comments, when I'm pressed for time.
Installation
Installation of this software is easy. It's a few commands, and a few prompts.
git clone https://git.sassysalamander.net/wytch/backup-scripts.git
cd backup-scripts
less install.sh #RTFC!
bash install.sh
Usage
If you want access to all the binaries in your path, you will have to edit the secure_path defaults in your /etc/sudoers file to gain access to it via sudo as a sudo-capable user.
sudo visudo
#/etc/sudoers
Defaults secure_path = <blah>:/opt/borg/bin
This will be fixed with the packaged version of this software, as by default the packaged version will install software to /usr/local/sbin, which is in the secure_path.
Alternatively, you can create a symlink.
sudo ln -s /opt/borg/bin/backup /usr/local/sbin/backup
sudo ln -s /opt/borg/bin/reposetup /usr/local/sbin/reposetup
Alternatively, you can create an alias in your shell rc file
#~/.bashrc
alias backup="sudo /opt/borg/bin/backup
alias reposetup="sudo /opt/borg/bin/reposetup
Use whatever method you prefer, they all accomplish the same thing, with different drawbacks.
Again, this problem will be solved for the packaged release.
To run the backup:
sudo screen -dmS backup /opt/borg/bin/backup
Screen will allow the process to continue running even if your terminal session dies.
You can do similar with tmux
sudo tmux new -ds backup '/opt/borg/bin/backup'
Or, if you like to live dangerously, you can just run
sudo /opt/bin/borg/backup
Scheduling backups
You can schedule backups using cron or systemd timers. I intend to write a systemd unit and timer for the final release, but for now the recommended setup would be to use a cronjob.
Either use one of the managed crons (cron.hourly, cron.daily) or set up a cronjob in your crontab
sudo crontab -e
#/etc/crontab
0 4 * * * /opt/borg/bin/backup
Will back up your machine every day at 4:00AM local time.
Contact
If you use this software, and encounter issues, I'd love to hear from you! If you want to contribute to this software, contact me and I'll consider creating an account for you.
IRC: wytch @ irc.libra.chat
PGP/Email: keys.openpgp.org - 0x38898A786F47B135
Final thoughts
I encourage you, once again, to read and understand all code in this repo. It is publicly available, as open source software. Knowledge is power. Take the power over your computing back. The best way to do that is to write your own software. The second best way to do that is to read and understand all the software you install. The third best way to do that is to verify software you do not trust.
Do not trust me. I'm just someone on the internet, writing software. Use your best judgement.