Jellyfin Forum
Questions about backups - Printable Version

+- Jellyfin Forum (https://forum.jellyfin.org)
+-- Forum: Support (https://forum.jellyfin.org/f-support)
+--- Forum: General Questions (https://forum.jellyfin.org/f-general-questions)
+--- Thread: Questions about backups (/t-questions-about-backups)



Questions about backups - fflam - 2024-12-09

Looking into properly backup my Jellyfin install, I came across this site. Jellyfin docs backup and restore Fairly straight forward, I run Jellyfin in a Debian LXC on Proxmox. so I just need to copy /var/lib/jellyfin and /etc/jellyfin. I noticed that contains the metadata folder, and for me that is currently over 50GB. as far as I can tell that folder just contains things like trickplay, posters, actor, and studio information. If i code to omit those files from the back up, if i have to restore it should be able to recreate/download all of that information again correct?  currently for me bandwidth is cheap, but physical storage is at a premium, so I'm looking for a way to reduce the size of my backups.


RE: Questions about backups - laughing_man77 - 2024-12-09

This may help you. Here's a copy of my backup/restore scripts. It assumes you're using docker (you can comment out the docker compose lines if you want). I only bother backing up the config and ignore the movies (they are stored separately for me, anyway), but if you want that too, uncomment the declaration for data_dir and the second tar command.
Other than that, replace the values for version, data_dir and backup_dir. Then run
Code:
./backup.sh

backup.sh:

Code:
#! /bin/bash
sudo docker compose down
version="10.10.3"
config_dir="relative/path/to/jellyfin/config"
# data_dir="relative/path/to/jellyfin/data"
backup_dir="relative/path/to/backup"
timestamp=$(date +%Y.%m.%d.%H.%M.%S)
if [ -z "${backup_dir}" ]; then
        mkdir ${backup_dir}
fi
cd ${backup_dir}
tar -zcvf jellyfin.config.${timestamp}_${version}.tgz ../${config_dir}
# tar -zcvf jellyfin.data.${timestamp}_${version}.tgz ../${data_dir}
cd -
sudo docker compose up -d

This is the restore script. It makes a backup of the existing config in backup_dir, so that you can restore the old config if anyting goes wrong. Depending on the number of parent directories to you config directory, you may need to edit --strip-components=2 (which strips leading directories from the path when it untars the archive). I haven't bothered creating a restore for the data dir, but you could easily run that manually with 
Code:
tar zxvf relative/path/to/data_archive.tgz -C relative/path/to/data/dir --strip-components=2

Edit the config_dir and backup_dir values, then run the script with:
Code:
./restore.sh path/to/config_archive.tgz

restore.sh:

Code:
#! /bin/bash
sudo docker compose down
backup_file=$1
config_dir="relative/path/to/jellyfin/config"
backup_dir="relative/path/to/backup/old_config"
if [ -z "${backup_file}" ]; then
        echo "no backup file given."
        exit 1
fi
if [ ! -f "${backup_file}" ]; then
        echo "backup file ${backup_file} does not exist."
        exit 1
fi
echo "moving existing config to $backup_dir"
if [ ! -d ${backup_dir} ]; then
        mkdir -p ${backup_dir}
fi
rm -R ${backup_dir}/* ${backup_dir}/.*
sudo mv ${backup_dir}/* ${backup_dir}/
echo "Restoring config"
tar zxvf ${backup_file} -C ${config_dir} --strip-components=2
sudo docker compose up -d



RE: Questions about backups - TheDreadPirate - 2024-12-09

You could probably omit the entire /var/lib/jellyfin/metadata/library folder. That is the largest folder, by far, and is replaceable. Keeping everything else should maintain watch status, media identification, playlists, etc.


RE: Questions about backups - fflam - 2024-12-14

Sorry for the late reply, had something come up.

laughing_man77 Thank you for the scripts. I don't use Docker but I am sure they will help. My question was more what files HAVE to be backed up, not about the back up process. Thank you none the less.

Quote: You could probably omit the entire /var/lib/jellyfin/metadata/library folder. That is the largest folder, by far, and is replaceable. Keeping everything else should maintain watch status, media identification, playlists, etc.

I figured as much, it seems to be mostly the image files for the metadata and trickplay information. I just wanted to be sure before I went and messed something up. Really the most important thing is the users login/password. other things would be annoying to lose, but that would be a pain to set up again.

Thank you