From fe40139838e75a162e5066c232f50a3f8e95402b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20I=C3=9Fbr=C3=BCcker?= Date: Sun, 16 Jun 2024 10:37:02 +0200 Subject: [PATCH] Make backup include preview images --- bookmarks/management/commands/full_backup.py | 13 +++++++++++++ docs/backup.md | 5 +++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/bookmarks/management/commands/full_backup.py b/bookmarks/management/commands/full_backup.py index 4924156..642c89e 100644 --- a/bookmarks/management/commands/full_backup.py +++ b/bookmarks/management/commands/full_backup.py @@ -48,6 +48,19 @@ class Command(BaseCommand): file_path = os.path.join(root, file) zip_file.write(file_path, os.path.join("favicons", file)) + # Backup the previews folder + if not os.path.exists(os.path.join("data", "previews")): + self.stdout.write( + self.style.WARNING("No previews folder found. Skipping...") + ) + else: + self.stdout.write("Backup bookmark previews...") + previews_folder = os.path.join("data", "previews") + for root, _, files in os.walk(previews_folder): + for file in files: + file_path = os.path.join(root, file) + zip_file.write(file_path, os.path.join("previews", file)) + self.stdout.write(self.style.SUCCESS(f"Backup created at {backup_file}")) def backup_database(self, backup_db_file): diff --git a/docs/backup.md b/docs/backup.md index e76e230..05f32dd 100644 --- a/docs/backup.md +++ b/docs/backup.md @@ -8,12 +8,13 @@ The data folder contains the following contents that are relevant for backups: - `db.sqlite3` - the SQLite database - `assets` - folder that contains HTML snapshots of bookmarks - `favicons` - folder that contains downloaded favicons +- `previews` - folder that contains downloaded preview images The following sections explain how to back up the individual contents. ## Full backup -linkding provides a CLI command to create a full backup of the data folder. This creates a zip file that contains backups of the database, assets, and favicons. +linkding provides a CLI command to create a full backup of the data folder. This creates a zip file that contains backups of the database, assets, favicons, and preview images. > [!NOTE] > This method assumes that you are using the default SQLite database. @@ -90,7 +91,7 @@ This is the least technical option to back up bookmarks, but has several limitat - It only exports your own bookmarks, not those of other users. - It does not export URLs of snapshots on the Internet Archive Wayback machine. - It does not export HTML snapshots of bookmarks. Even if you backup and restore the assets folder, the bookmarks will not be linked to the snapshots anymore. -- It does not export favicons. +- It does not export favicons or preview images. Only use this method if you are fine with the above limitations.