No description
Find a file
2026-09-11 13:37:43 +02:00
backup-etc.sh changed backup target path 2026-09-11 13:37:43 +02:00
README.md readme 2026-08-30 20:12:03 +02:00

/etc Backup Script

A small Bash script that creates compressed backups of /etc on the Rigel server.

Backups are stored as .tar.zst archives on the betelgeuse storage and the script sends a notification through ntfy when the backup succeeds or fails.

What it does

The script:

  1. Checks that the backup storage is actually mounted.
  2. Creates the backup directory if necessary.
  3. Archives /etc using tar.
  4. Compresses the archive with Zstandard (zstd).
  5. Keeps only the 7 most recent backups.
  6. Sends an ntfy notification when the backup succeeds.
  7. Sends a high-priority ntfy notification if the storage mount is missing.

Backup location

Backups are stored in:

/mnt/betelgeuse/katz/filepile/backup/rigel/etc/

Files are named using the following format:

etc-YYYY-MM-DD_HH-MM-SS.tar.zst

For example:

etc-2026-08-30_20-15-42.tar.zst

Safety check

Before doing anything, the script verifies that:

/mnt/betelgeuse/katz/filepile

is an actual mounted filesystem.

If it isn't mounted, the script aborts immediately.

This is important because it prevents a backup from accidentally being written to the underlying local directory instead of the intended storage.

An error notification is also sent through ntfy.

Compression

The backup uses:

tar --zstd

The resulting .tar.zst file is a normal tar archive compressed with Zstandard.

It can therefore be inspected or restored without this script running.

List the contents

tar --zstd -tf etc-2026-08-30_20-15-42.tar.zst

Extract the backup somewhere else

mkdir /tmp/etc-restore
tar --zstd -xpf etc-2026-08-30_20-15-42.tar.zst -C /tmp/etc-restore

The etc directory from the backup will then be available under:

/tmp/etc-restore/etc/

Retention

After a successful backup, the script keeps the 7 newest backup files.

Older backups are automatically deleted.

For example, if there are 10 backups:

backup 10  ← newest
backup 9
backup 8
backup 7
backup 6
backup 5
backup 4
backup 3  ← oldest retained
backup 2  ← deleted
backup 1  ← deleted

Notifications

Notifications are sent through ntfy.

The configured topic is:

rigel

The backup script uses the notification title:

rigel_etc_backup

A successful backup reports the name of the newly created archive.

A missing backup mount generates a high-priority notification.

Notification failures do not cause the backup itself to fail because notification commands are deliberately allowed to fail with || true.

Requirements

The following commands must be available:

  • bash
  • tar
  • zstd
  • curl
  • mountpoint
  • ls
  • xargs
  • rm

On Debian, these are normally available with the standard system installation, with zstd and curl being the notable packages to check.

You can verify the important ones with:

command -v tar zstd curl mountpoint

Running manually

Make the script executable:

chmod +x backup-etc.sh

Then run:

./backup-etc.sh

A successful run will create a new archive and send an ntfy notification.

Automation

The script is intended to be run automatically, for example through a systemd timer.

The script itself does not contain any scheduling logic, so it can also be run from cron or another scheduler.

Important security note

The ntfy authentication credential should not be committed to Git.

Keep secrets outside the repository where possible, for example in a protected environment/configuration file with permissions:

chmod 600 <secret-file>

If the authentication token currently exists in the script, consider moving it out before committing the script to a Git repository.

Repository

This script is maintained in Git and can be hosted on the local Forgejo instance.

The repository should contain the script and this README, but not credentials, passwords, tokens, or generated backup archives.