advplyr / audiobookshelf

Self-hosted audiobook and podcast server
https://audiobookshelf.org
GNU General Public License v3.0
6.43k stars 456 forks source link

[Enhancement]: Splitting backups into author/item and database backups with separate backup schedules #3477

Open ZLoth opened 1 week ago

ZLoth commented 1 week ago

Type of Enhancement

Server Backend

Describe the Feature/Enhancement

Split the backups into two: One being the author/item images backup (metadata-authors and metadata-items respectively, and one being the database (aka absdatabase.sqlite), and each having their own backup schedule (images being on a weekly schedule, while the database is on a daily schedule).

Why would this be helpful?

My library consists of over 5,000 titles, thus there is a high number of images for both the titles and authors that can't be further compressed well as well as the database which compresses very well. See the example below where I show the sizes both uncompressed and compressed:

image

Now I fully understand the reason why you want to have a daily backup of the database as it contains current book status as well as user list. As you can see, the uncompressed database dump is around 630MB while the compressed version is just 70.8MB for my large library.

But, the images, once created, rarely change, thus they may be backed up on a more infrequent schedule (e.g. weekly with a option for a manual backup) with the possibility that you may have to run a match to recover the images of the most recent titles. The images are already in compressed jpg format, and take up 1.49 GB. That is plenty of data that doesn't change, and could benefit from a less-frequent backup schedule with detection that if nothing changed, the backup doesn't get created.

The reason why I mention this is because of how I backup on my server. As I am running under a docker container, I have a mapping from the /metadata/backups within the docker container to the /mnt/pool/backup/Audio BookShelf folder on my server. In turn, I have a nightly job which backs up the on-site /mnt/pool/backup folder (which also includes computer backups) to an offsite backup at Backblaze. A daily backup looks like this online with two days retention of deleted files:

image

Future Implementation (Screenshot)

For backups: image

For restores: image

Audiobookshelf Server Version

v2.13.4

Current Implementation (Screenshot)

image

ZLoth commented 2 days ago

Very rough versions of the backup screens uploaded.

ZLoth commented 1 day ago

One possibility that was raised in the Discord channel by @nichwall is to store the metadata.json and images along with the books (items), and have just the database be backed up. I'm completely open to that idea, as I backup my books on a regular basis to a large hard drive. Here are my options:

image

Also storing the book as a metadata.json file will help with moving books between libraries, especially if the scanner order is like this:

image