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.

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

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

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

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

    # Custom preparation scripts to run.
        -  systemctl stop jellyfin

        - 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.