Posted on 1 Comment

Linux Snippet – Backing Up Jellyfin With Borgmatic

Having had a wee issue with Jellyfin Media Server’s database this week after an upgrade, I decided to avoid the requirement for a 24 hour database rebuild, to start backing things up with Borgmatic. Borgmatic is a handy wrapper script to automate BorgBackup.

location:
    # List of source directories to backup.
    source_directories:
        - /etc/jellyfin
        - /var/lib/jellyfin

    # Path to BorgBackup repository
    repositories:
        - /export/ServerData/jellyfin_database

retention:
    # Retention policy for how many backups to keep.
    keep_daily: 7

consistency:
    # List of checks to run to validate your backups.
    checks:
        - repository
        - archives

hooks:
    # Custom preparation scripts to run.
    before_backup:
        -  systemctl stop jellyfin

    after_backup:
        - systemctl start jellyfin

This is a very simple configuration, which does the following steps:

  1. Stops the Jellyfin server
  2. Runs Borg on both configuration directories – /etc/jellyfin & /var/lib/jellyfin.
  3. Checks the repo & existing archives for consistency
  4. Restarts the Jellyfin server.

Now, whenever the SQLite 🤮 databases backing up the frontend decide to have a shitfit, it should be a relatively simple matter to restore to the last good backup. In my case I have a cronjob set to run every night. Once someone adds proper MySQL support, I will migrate over to a proper database server instance. 😉

1 thought on “Linux Snippet – Backing Up Jellyfin With Borgmatic

  1. How would one go about restoring?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.