2024-12-09, 09:49 AM
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
backup.sh:
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
Edit the config_dir and backup_dir values, then run the script with:
restore.sh:
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