Back to Article List

Immich backup: How to back up your library and database

Immich backup: How to back up your library and database - Immich backup: How to back up your library and database

Updated and tested 2 November 2026

Of everything on your servers, the photo library is the dataset with no second chance: configs can be rebuilt, media can be re-ripped, but the kids' photos exist exactly once. So Immich backup deserves doing properly, and the good news is the project meets you halfway with automatic database dumps built in. The other half, the actual photo files and getting copies off the machine, is on you. Here's the complete arrangement, sized for a normal self-hoster's patience.

Database and files: the two halves of an Immich backup

Immich's state splits cleanly. The database holds everything you've done in the app: users, albums, face names, favorites, edited metadata, the map of which file belongs to whom. The files under UPLOAD_LOCATION hold the photos themselves. Lose the database and keep the files: painful re-import, albums and faces gone. Lose the files and keep the database: catastrophe, the database is a beautiful index of nothing. A real backup covers both, and they travel together, ideally from the same moment in time.

Half one: the built-in database dumps

Every Immich server ships with automatic database backups already running: a dump lands in UPLOAD_LOCATION/backups daily at 2:00 AM, with the last 14 kept, per the official backup docs. Administration » Settings » Database Dump Settings adjusts the schedule and retention. Check yours exists right now (ls /opt/immich/library/backups with the install guide's paths); a fresh .sql.gz with today's date is the system working.

ls in /opt/immich/library/backups lists immich-db-backup-20261101T224508-v3.3.5-pg14.19.sql.gz

One dump in the backups folder; the name carries the UTC time, the Immich version and the Postgres version.

Immich Database Dump Settings: dumps enabled, preset Every night at 2am, cron 0 02 * * *, keep 14 previous dumps

The defaults on a fresh v3.3.5 install: a dump every night at 2am, the last 14 kept.

Restoring got civilized in recent versions too: Administration » Maintenance lists the dumps with a Restore button, and a fresh install's onboarding offers restore-from-backup directly. The command-line route (stop containers, feed the dump to Postgres, restart) remains for disaster scenarios, but for the common "undo the last bad day" the button does it.

One dump-related habit worth adopting: take a manual dump before major version updates, on top of the nightly ones, since majors are when database migrations happen and the pre-migration state is the one you can't recreate afterwards. That routine and why downgrades need it are covered in the Immich update guide.

Half two: back up the files (and what to skip)

Inside UPLOAD_LOCATION, not everything deserves backing up. The must-haves are upload/ (the originals your phones sent), library/ (originals when the storage template is on) and profile/ (avatars, tiny). The skippables are thumbs/ and encoded-video/, both derived data Immich regenerates on demand; leaving them out cuts backup size by a third or more at the cost of a regeneration job after a restore. The backups/ folder with the database dumps rides along, which conveniently keeps both halves in one copy operation.

The tool barely matters; the offsite part does. A nightly rsync to any second machine covers the honest minimum:

rsync -a --delete --exclude 'thumbs' --exclude 'encoded-video' \
  /opt/immich/library/ backup-host:/backups/immich/

The folder on the far side has to exist and rsync has to be installed on both machines. I ran this line against a local folder in place of a second host: it copied backups/, library/, profile/ and upload/ and left out thumbs and encoded video.

The rsync copy holds backups, library, profile and upload but no thumbs or encoded-video: 60M in 17 files

The rsync line copied backups, library, profile and upload and left thumbs and encoded-video behind.

A step up in seriousness is a real backup tool with versioning and encryption (restic and borg are the community favorites, and Immich's docs point the same direction), which protects you from the failure rsync can't: a deletion or corruption mirrored faithfully to the backup before you notice it. Versioned snapshots mean last Tuesday still exists. Cron either approach nightly, an hour after Immich's own 2 AM dump so the fresh database rides along.

Where to send it: any second location beats none, and the options stack. Another machine at home, a cheap object bucket or a second VPS. Layer zero, worth stating for VPS folks: the provider-side snapshot protects against whole-machine loss in one click, and pairs with rather than replaces the file-level backup, because "restore the whole server to Thursday" and "recover one album" are different tools.

Never delete a memory again

Keep every photo and video of the people you love, on reliable storage with unmetered bandwidth and a cost that stays predictable as the years add up.
Billing Cycle

VPS.H1

$6.99 Save  14 %
$5.99 Monthly
  • 1 vCPU AMD EPYC
  • 2 GB RAMMEMORY
  • 750 GB HDDSTORAGE
  • Unmetered bandwidth
  • IPv4 & IPv6IPv6 is currently unavailable in France, Finland or the Netherlands. included

VPS.H3

$24.99 Save  20 %
$19.99 Monthly
  • 4 vCPU AMD EPYC
  • 8 GB RAMMEMORY
  • 2500 GB HDDSTORAGE
  • Unmetered bandwidth
  • IPv4 & IPv6IPv6 is currently unavailable in France, Finland or the Netherlands. included

VPS.H4

$36.49 Save  18 %
$29.99 Monthly
  • 6 vCPU AMD EPYC
  • 12 GB RAMMEMORY
  • 3500 GB HDDSTORAGE
  • Unmetered bandwidth
  • IPv4 & IPv6IPv6 is currently unavailable in France, Finland or the Netherlands. included

Test the restore procedure

An untested backup is a mood, not a plan, so run the drill one time: spin up a scratch VPS or VM, install Immich the normal way, copy your backed-up UPLOAD_LOCATION into place, choose restore-from-backup during onboarding (or the Maintenance restore afterwards) and confirm your albums, faces and a random photo from 2019 all survived. Then tear it down. The exercise takes an evening, converts your backup from theory to fact and doubles as the documented procedure for the day you migrate servers on purpose.

When I ran the drill, the restore screen first checked the folders and flagged profile/ in red as missing files, with thumbs/ and encoded-video/ in amber. The red mark was about my drill copy, whose profile/ folder was empty; the amber ones are the two folders the rsync line leaves out, and the restore went ahead. The wizard backs up the current database first, then restores the dump you pick; for my 18 MiB dump the whole restore took about 50 seconds.

Immich Restore Your Library check: profile is missing files in red, encoded-video and thumbs missing files in amber

The pre-check on my drill flagged profile in red, which is expected when the backed-up profile folder is empty.

Immich Restore From Backup list with immich-db-backup-20261101T225900-v3.3.5-pg14.19.sql.gz, 18.3 MiB, and a Restore button

The dumps from the copied backups folder show up in the list, each with its own Restore button.

Thumbnails are not in the backup, so the timeline shows "Error loading image" until they're rebuilt: run Administration » Job Queues » Generate Thumbnails with All. Missing did nothing on my restored copy; All fixed it in about 20 seconds.

Drilling on the same server instead of a scratch one needs two precautions. The official compose file hard-codes name: immich, so a second docker compose up -d from another folder replaced my live stack's containers (the data on disk was untouched); change the name: line, the container_name lines and the host port in the drill copy first. And open the drill in a private window or under another hostname, because logging in to one instance logged me out of the other: the browser keeps one login cookie per host, whatever the port.

Steady state, this whole system is two cron lines and a monthly glance: dumps happening (a current file in backups/), sync happening (recent timestamps on the far side) and disk not creeping toward full. That's the entire price of the one dataset in the house that genuinely can't be bought back, which seems like a fair trade to me.

Questions?

Why does a command-line restore fail with role "immich" does not exist?

The database name and the user name are swapped in the restore command. In the stock .env the user is DB_USERNAME=postgres and the database is DB_DATABASE_NAME=immich, and the backup docs' command takes --username from the first and --dbname from the second. That mix-up was the accepted answer in GitHub discussion #16981, and with the flags the right way round the poster's restore worked. A dump made before v2.5.0 needs the older restore instructions, which the docs keep behind their version selector.

Never run out of space again

Keep backups, archives and media on reliable storage with unmetered bandwidth and a cost per gigabyte that stays low as the years add up. Your first VPS comes with a 30-day money-back guarantee.