Auto backup

Hi there,

Im trying to follow this post to have an automatic backup done but cant seem to get it to work. Please could someone help?

My drive is /var/media/KODI/

I did create an addon so I can just click to start

the default.py is this
import os
os.system(‘sh /var/media/KODI/backup.sh’)

Please post your script that does not work and explain what the issue is.

Automatic when, daily, hourly, on reboot, on kodi restart. When???

#!/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

How do you execute it? And does USB stick really has name KODI (all uppercase)? Is it mounted under /media/USB ?

You might like my backup:

#!/bin/sh
# script backup.sh
cd /media/5TB-HDD/.backups/ && tar -cvf $(date +%Y%m%d%H%M%S).tar \
  --exclude=Thumbnails --exclude=.thumbnails \
  /storage/.kodi /storage/.cache /storage/.config /storage/.ssh
find /media/5TB-HDD/.backups -name "*.tar" -type f -mtime +7 -exec rm -f {} \;

It runs every every three days at seven in the morning via crontab.conf.

# script crontab.conf
0 7 */3 * * /storage/.config/scripts/backup.sh
15 7 * * * systemctl reboot

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

About | FAQ | Terms of Service | Privacy Policy | Legal Notice