A collection of bash scripts to be used on Linux. All scripts are MIT licensed.
This repository has been archived on 2025-04-03. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
2024-07-14 11:28:23 +02:00
borgmatic Moved scripts to separate folders, started working on GitLab to Gitea migration script 2024-07-13 16:16:38 +02:00
gitlab2gitea Code cleanup / restructuring 2024-07-14 11:28:23 +02:00
ufw Moved scripts to separate folders, started working on GitLab to Gitea migration script 2024-07-13 16:16:38 +02:00
.gitignore chore: Add .env and *.log to .gitignore 2024-07-13 17:14:46 +02:00
LICENSE Moved scripts to separate folders, started working on GitLab to Gitea migration script 2024-07-13 16:16:38 +02:00
README.md fixed borgbackup links 2024-07-13 16:17:41 +02:00

Linux Scripts Collection by Zion Networks

Who is Zion Networks?

We are a Berlin-based startup focussed on IT Consulting, Administration services, Software and Game Development and AI. Professional and customer-oriented solutions are our passion.

Since we use open source software every day it's also our resposibility to give something back.

We're planning to release a growing amount of open source software, that is free to use for personal and commercial applications.

What scripts can be found here?

Name Description License Current Version Written in Supported Distros File
Borgmatic Setup Tool If you plan to use borg as backup solution, you should also take a look at borgmatic. It's a Python wrapper for the award winning backup tool borgbackup that simplifies creating secure and reliable backups even more. You can even store your configurations in files. This script will do the setup for you to. MIT v1.2.1 Bash Debian and derivates bormatic_setup.sh

Borgmatic Setup Tool

With the Borgmatic Setup Tool (BST) you can setup scheduled incremental backups in seconds. The tool is designed to be beginner friendly, but can also save a lot of time for experts.

Basically it will install all required tools on the machine you want to backup, like borgbackup or pipx. You can choose between a fully automated installation, a partially automated installation (the script will prompt for passwords) or an interactive installation.

For beginners, the fully automated installation is recommended.

Note: As of the time of writing, the script requires to be run as root. The reason is, that in most cases you want to backup directories that require root permissions to be read, such as /home or /etc.

Available command-line options

BST offers several command-line options to automate the whole process and get your backup schedule ready to go as fast as possible.

These options are available in version 1.2.1:

-a, --auto: Enable automatic, non-interactive mode
-n, --no-upgrade: Skip package upgrades
-d, --debug: Enable debug mode
-f, --first-backup: Run the first backup after setup
-o, --override-crontab: Override the existing crontab file
-c, --override-config: Override the existing borgmatic configuration file
-r, --override-repository: Override the existing backup repository
-s, --upgrade-required: Upgrade only required packages
-u, --upgrade-all: Upgrade all installed packages
-v, --version: Show script version
-h, --help: Show help message

-R, --repo: Set the backup repository path
-E, --encryption: Set the encryption method
-P, --passphrase: Set the backup passphrase (if set but empty, the script will ask for the passphrase)
-D, --dirs: Set the backup directories (separated by space as a string, for example: --dirs "/etc /var/log /home")
-L, --label: Set the backup label prefix
-S, --schedule: Set the cron schedule

-H, --host: Set the backup server hostname or IP address
-P, --port: Set the backup server SSH port
-U, --user: Set the backup server SSH user
-W, --password: Set the backup server SSH password (if set but empty, the script will ask for the password)
-K, --key-name: Set the SSH key name
-T, --key-type: Set the SSH key type
-F, --key-file: Set the SSH key file path
Fully automated setup

To run a fully automated setup you need to set the --auto or a flag. This will cause the script to skip some prompts.

If you want the script to also upgrade the packages on your system, set the --upgrade-all or --upgrade--required flag, depending on your needs. If neither are given, the script won't upgrade any already installed packages.

Example: Backup local configurations and home directories
  1. Get the script via wget or curl:
    1. wget https://git.zion-networks.de/ZionNetworks/linux-bash-scripts/raw/branch/main/borgmatic/borgmatic_setup.sh
    2. curl -O https://git.zion-networks.de/ZionNetworks/linux-bash-scripts/raw/branch/main/borgmatic/borgmatic_setup.sh
  2. Set the execution flag using chmod +x borgmatic_setup.sh
  3. Run the script:

sudo ./borgmatic_setup.sh -a -f -R "/mnt/backups/my-host" -E "none" -D "/etc /home" -S "0 3 * * *" -H "my.backup.host" -U "backupuser" -W

Let's break up this script:

  1. -a enables the automatic mode, so the user will see no prompts unless it's required
  2. -f will cause the script to run a first backup when the setup is done
  3. -R is the path to the backup directory on the remote machine
  4. -E is the parameter for the backup repository encryption - we're using none here, so the repository won't be encrypted. You can also use repokey which requires the option -P to be set (either with value, like -P "my_secret_key" (not recommended!) or just -P to let the script prompt for the passphrase)
  5. -D sets the local directories that should be backed up
  6. -S is the schedule in cron syntax - 0 3 * * * will run the backup every day at 3 AM
  7. -H is the hostname or IP address of the machine, where the backups should be stored
  8. -U is the username to be used to connect to the backup host via ssh
  9. -W will cause the script to prompt for the password of the user (you can also provide the password like -W "my_ssh_password", but that is NOT recommended!)

This will cause the script to:

  1. Install all required packages to perform the backups on your local machine
  2. Connect to the remote host to:
    1. Copy over a newly generated SSH key which is only used to do the backups
    2. Install borg on the remote machine
  3. Generate the borgmatic configuration based on your parameters (this will be stored at /etc/borgmatic/config.yaml)
  4. Create the repository on the remote machine
  5. Do the first backup based on your configuration
Planned Features
  • Support for more distros
  • Support for database backups
  • Support for local backups / backups to media devices
  • Pre-Backup commands
  • Post-Backup commands
  • Add support to run, restore, prune, check, delete and list backups
  • Add support for multiple backup repositories
  • Add support for multiple backup configurations
  • Add support for multiple backup servers