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 is this
import os
os.system(‘sh /var/media/KODI/’)

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

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

#Purpose = Backup Kodi
#save this file to /storage/.kodi/userdata/
#define your backup-directory


#number of backups, which exists after the script will have been finished = NUM+1
#50 backups to be saved
ls -1tr "$DESTDIR"/*.tar | head -n -$NUM | while read -r i
  rm "$i"

TIME=`date +%Y%m%d%H%M%S` 	# date in backup name.
FILENAME=$TIME.tar 			# Backup Name

SRCDIR="/storage/.kodi/ /storage/.cache /storage/.config/"


The above is saved as 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/')

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:

# script
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/
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).

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.