Skip to content

Commit

Permalink
Make backup include preview images
Browse files Browse the repository at this point in the history
  • Loading branch information
sissbruecker committed Jun 16, 2024
1 parent 44b49a4 commit fe40139
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
13 changes: 13 additions & 0 deletions bookmarks/management/commands/full_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ def handle(self, *args, **options):
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):
Expand Down
5 changes: 3 additions & 2 deletions docs/backup.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.

Expand Down

0 comments on commit fe40139

Please sign in to comment.