Backup of headless LE/thveadend on Rpi?

  • Sorry if this is a noob question. is it possible to do a LE backup, including the TVH setup, from an ssh command line? I know I can do it from inside Kodi, but the Rpi is in a small cupboard with no monitor nearby (it's used only as a TVH server). I really only care about TVH, but it doesn't seem to have a backup option that I can see.

    Failing any success here, I will power off and clone the SD card, but just wondering.

  • Code
    systemctl stop kodi.service
    tar -cvf mybackup.tar /storage/.kodi
    systemctl start kodi.service
  • Code
    systemctl stop kodi.service
    tar -cvf mybackup.tar /storage/.kodi
    systemctl start kodi.service


    Sorry to bring this old thread up again, but i want to create a auto backup as well.

    I am new to Linux/LE and I got the cronjop working so far. But I have a question regarding stopping/starting the kodi service. Is this mandatory to get a consistent backup? I am asking, because the backup job seem to work properly as well while using Kodi+Tvheadend when backing up.


  • Thank you, CvH :thumbup:

    So I am going to run the backup job streight after booting the machine to not interupt any potential recordings

  • Just stop kodi forever if it's running as server only ;) I have set it up this way :)

    This is my
    sleep 10;
    if systemctl stop wpa_supplicant kodi service.tigervnc docker.linuxserver.portainer pulseaudio; then
        echo "Services stoped"
        echo "Error"

    Then I call another script from cron to backup stuff every 24h ;)

    tar -cpf /storage/backup/backup-$(date +%F).tar /storage/.config /storage/.kodi /storage/.ssh /storage/.ash_history /storage/.cache
  • Thank you for your advice Borygo77

    Server only doesn't work for me as both, kodi and Tvheadend run on my main HTPC.

    But backing up more than just .kodi makes sense.

    Maybe a stupid question:

    Does the restore function with LibreELEC do the job for the other folders as well (/storage/.config /storage/.ssh /storage/.ash_history /storage/.cache)?

    Currently my shell looks like this

    I am struggling with the find command as -exec needs another attribute, but I'm sure I will get that to work as well :)

    ...I might have to increase the the second sleep for the full backup...


  • It does bub 😊 it will replace any file you have backed up with tar 👍 what I found is Libreelec does need to have proper name of the file to restore it.

    20191124141244.tar this file will be restored alright but this one backup-2020-01-31.tar not 🙈 and I don't know why

    This is my delete script called from cron and it does the job for me alright 😉

    find /storage/zew/backup/auto_backup -mtime +4 -type f -delete

    It deletes any files and folders older than 4 days.

  • Hi All,

    I am still struggling with the automated backup.

    I wrote following scrip to execute with a cronjob.

    The script works 100% fine when I execute it manually (./

    It does not work properly when started via cron and I don't see why.

    When started via cron, all is executed properly except the rsync job.

    Does anyone have a clue?


  • My intension was having different backup states while doing full backups once a week.
    ... when using kodi under windows with dvbviewer, I had to fully restore kodi many (many) times.


  • Set complete environment for your cron job, see Cron problem sh file

    wow - it works now - thanks so much!!

    But it remains a kind of untraceable for me why only parts of the script were executed.

    I mean because crontab found the .sh but excluded the rsync.

    anyway. Thanks again

  • rsync is part of the Network Tools but /storage/.kodi/addons/ is not part of the default (cron) PATH.

    Sourcing /etc/profile adds the addon paths to PATH.