#!/bin/bash
#Purpose = Backup Kodi
#save this file to /storage/.kodi/userdata/backup.sh
#define your backup-directory
DESTDIR="/var/media/KODI/"
#DESTDIR=/storage/backup/
cd "$DESTDIR"
#number of backups, which exists after the script will have been finished = NUM+1
#50 backups to be saved
NUM=4
ls -1tr "$DESTDIR"/*.tar | head -n -$NUM | while read -r i
do
rm "$i"
done
TIME=`date +%Y%m%d%H%M%S` # date in backup name.
FILENAME=$TIME.tar # Backup Name
SRCDIR="/storage/.kodi/ /storage/.cache /storage/.config/"
SRCDIR_EXCLUDE="--exclude=storage/.kodi/userdata/Thumbnails"
tar cvf "$DESTDIR/$FILENAME" $SRCDIR_EXCLUDE $SRCDIR
The above is saved as backup.sh and put on my KODI usb stick.
I have a script that I can execute in kodi
import os
os.system('sh /var/media/KODI/backup.sh')
Should be executed whenever I run my script. Nothing at all happens no backups nothing
The main difference is that you don’t place the ‘tar’ command (with the ‘cd’ command) in any directory and that has given me errors that I can’t explain (linux mysteries, maybe the problem is when the ‘tar’ command uses some temporary file in the working directory and it is part of the backup).