MariaDB add-on, Docker containers - is it safe to backup while running?

  • RaspberyPi4, 4GB, LibreELEC v9.2.8 with MariaDB addon, Docker addon and a few containers: Portainer CE, WordPress (official), HomeAssistant, PiHole.

    Is it safe to use the LibreELEC backup function while these services are running? I'm worried that a backup made while SQL databases are being written will contain corrupted database files, and possibly other problems related to files being backed up while in an inconsistent state.

    So far I restored a backup twice and it worked, but that might be just luck?

    Thanks.

  • I have been using docker for a year and a half with LibreELEC and services like tvheadend, syncthing, and many others created by expert programmers. I have never seen any issues with my backups running automatically every three days at four in the morning.

    I think that any professional programmer takes into account the protection of their software against power, hardware or any other type of failure, validating the tasks only when they have been completed without failure and in a single CPU clock cycle.

  • I worked in IT for 25+ years. I would make zero assumptions that any developer expected their code to run in a container on a cheap ARM board device and considered how that might affect transactional integrity in backups. That said, the rate of change in MariaDB from Kodi use is probably low enough that you will get away with our backup process. The best thing to do with backups is a) take them regularly, b) store them off the device that can go wrong, c) prove you can restore them too (not all the time, but occasionally).

  • I'm worried that a backup made while SQL databases are being written will contain corrupted database files, and possibly other problems related to files being backed up while in an inconsistent state.

    SQL databases especially, depending on the configuration there can be data loss as it is not unusual to hold changes into a buffer cache and write them to disk later. Typically I do a backup with mysqldump (as a hot backup) and as chewitt mentioned the changes to the Kodi db are pretty low volume. Since my backups are daily there could be up to 24h of data loss, but really the only loss for me is watch counts as the data comes from NFO files on the sources.

    I would investigate each applications backup options, and follow their guidance. This may mean you need to write a cron script and use "docker exec" to run the backup command in the running container. You will need to adjust your docker configuration to probably include some volume for storing backups.

  • I'll try to use cron to run a script that stops containers and DB and then run the backup.

    I want to be able to restore the backups using LibreELEC restore, just like an "original" backup made by LibreELEC. I saw that LibreELEC backups contain just some of the directories in /storage, not entire /storage. Can you tell me the tar command used by LibreELEC? (Or where can I find it?)

    Can I still use LibreELEC restore if I gzip it?

    Thank you.

  • I am going to give you as an example the backup script that I have used for a long time without any problem, modify it to your liking, naturally it is 100% compatible with the LibreELEC restore.

    #!/bin/sh

    # full backup

    cd /media/5TB-HDD/.Backups/le-backup/ && tar -cvf $(date +%Y%m%d%H%M%S).tar \

    --exclude=Thumbnails --exclude=.thumbnails --exclude=.acestream_cache \

    /storage/.kodi /storage/.cache /storage/.config /storage/.fluxbox /storage/.ssh

    find /media/5TB-HDD/.Backups/le-backup -name "*.tar" -type f -mtime +7 -exec rm -f {} \;