<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Homelab Backup: NAS, VM and Offsite Backup</title><description>Plain guides to NAS, virtual machine and offsite backup for homelabs, built from published official documentation.</description><link>https://homelabbackup.com/</link><language>en</language><atom:link href="https://homelabbackup.com/rss.xml" rel="self" type="application/rss+xml"/><item><title>Backblaze B2 vs Wasabi vs Hetzner vs R2 for NAS Backup</title><link>https://homelabbackup.com/posts/backblaze-b2-wasabi-hetzner-r2-nas-backup/</link><guid isPermaLink="true">https://homelabbackup.com/posts/backblaze-b2-wasabi-hetzner-r2-nas-backup/</guid><description>Compare Backblaze B2, Wasabi, Hetzner and Cloudflare R2 for NAS backup. See how storage fees and restore costs differ, then try a small restic restore.</description><pubDate>Thu, 26 Nov 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Start with Backblaze B2 if you want usage-based billing and expect downloads to stay within three times your average monthly storage. Consider Wasabi for long-lived backups and light downloads, or Hetzner Object Storage if its bundled storage and transfer fit your usage. Choose Cloudflare R2 Standard if avoiding direct egress charges matters more than the storage rate. &lt;a href=&quot;https://www.backblaze.com/cloud-storage/pricing&quot;&gt;Backblaze pricing&lt;/a&gt; · &lt;a href=&quot;https://wasabi.com/pricing/faq&quot;&gt;Wasabi pricing FAQ&lt;/a&gt; · &lt;a href=&quot;https://docs.hetzner.com/storage/object-storage/overview/&quot;&gt;Hetzner billing&lt;/a&gt; · &lt;a href=&quot;https://developers.cloudflare.com/r2/pricing/&quot;&gt;R2 pricing&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;What you pay to store and restore backups&lt;/h2&gt;
&lt;p&gt;Egress is data transferred out of the bucket. A restore can incur request or retrieval charges even when the provider charges nothing for egress. &lt;a href=&quot;https://developers.cloudflare.com/r2/pricing/&quot;&gt;R2 pricing&lt;/a&gt;&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Service&lt;/th&gt;
&lt;th&gt;Storage and minimums&lt;/th&gt;
&lt;th&gt;Downloads and requests&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Backblaze B2 Pay as You Go&lt;/td&gt;
&lt;td&gt;Listed rate of $6.95 per TB per 30 days. No minimum storage duration fee.&lt;/td&gt;
&lt;td&gt;Direct egress is free up to 3× your average monthly storage, then $0.01/GB. Class A, B and C requests are free on Pay as You Go. &lt;a href=&quot;https://www.backblaze.com/cloud-storage/pricing&quot;&gt;Backblaze pricing&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wasabi Object Storage Pay as You Go&lt;/td&gt;
&lt;td&gt;In the US and Europe, storage costs $7.99 per TB per month. Pay as You Go has a minimum monthly charge based on 1 TB of active storage, even if you store less. Deleting an object before 90 days can incur a storage charge for the remaining days.&lt;/td&gt;
&lt;td&gt;Wasabi&apos;s free egress policy is designed for monthly downloads at or below your active storage volume. Wasabi may limit or suspend service if you regularly exceed that volume. Free API requests have a separate reasonable-use policy. &lt;a href=&quot;https://wasabi.com/pricing/faq&quot;&gt;Wasabi pricing FAQ&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hetzner Object Storage&lt;/td&gt;
&lt;td&gt;The German base charge is capped at €7.72 per month including German VAT. The account-wide base charge accrues hourly whenever at least one bucket is active, even if it&apos;s empty. It covers 1 TB of billable storage held throughout a full month.&lt;/td&gt;
&lt;td&gt;Storage and egress allowances accrue with active hours and are shared across buckets. Storage and egress above those allowances are billed separately. S3 operations such as PUT, GET and DELETE are free. &lt;a href=&quot;https://www.hetzner.com/de/storage/object-storage/&quot;&gt;German pricing&lt;/a&gt; · &lt;a href=&quot;https://docs.hetzner.com/storage/object-storage/overview/&quot;&gt;Hetzner billing&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cloudflare R2 Standard&lt;/td&gt;
&lt;td&gt;$0.015 per GB-month with no minimum storage duration. The monthly Standard allowance includes 10 GB-month.&lt;/td&gt;
&lt;td&gt;Direct egress is free. Operations cost $4.50 per million Class A requests and $0.36 per million Class B requests beyond the monthly allowances of 1 million and 10 million, respectively. &lt;a href=&quot;https://developers.cloudflare.com/r2/pricing/&quot;&gt;R2 pricing&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;R2 also offers Infrequent Access at $0.01 per GB-month. It adds a $0.01/GB retrieval fee, higher Class A and Class B request rates and a 30-day minimum storage duration. &lt;a href=&quot;https://developers.cloudflare.com/r2/pricing/&quot;&gt;R2 pricing&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;What two full downloads cost&lt;/h3&gt;
&lt;p&gt;Suppose you store 1 TB for an entire 30-day billing period and two restores each transfer 1 TB directly to your NAS. The transfer total is 2 TB. Here&apos;s how each provider treats it.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Backblaze B2:&lt;/strong&gt; 2 TB fits within the 3 TB free egress allowance for 1 TB of average monthly storage. &lt;a href=&quot;https://www.backblaze.com/cloud-storage/pricing&quot;&gt;Backblaze pricing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Wasabi:&lt;/strong&gt; 2 TB exceeds the free egress guideline for 1 TB of active storage. &lt;a href=&quot;https://wasabi.com/pricing/faq&quot;&gt;Wasabi pricing FAQ&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Hetzner:&lt;/strong&gt; 2 TB exceeds the 1.08 TB egress allowance for a 30-day month with a bucket active throughout. The excess is billable. &lt;a href=&quot;https://docs.hetzner.com/storage/object-storage/overview/&quot;&gt;Hetzner billing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;R2 Standard:&lt;/strong&gt; Direct egress costs $0. Using 1,000 GB-month for the storage line, subtract the Standard allowance, then multiply 990 GB-month by $0.015 to get $14.85 before any request charges. &lt;a href=&quot;https://developers.cloudflare.com/r2/pricing/&quot;&gt;R2 pricing&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Connect a test bucket to restic&lt;/h2&gt;
&lt;p&gt;Use a new bucket and run restic on a machine that can read a small NAS folder. Use the bucket and access-key setup in the links below. For R2, leave the bucket&apos;s storage class at its default, Standard, for the pricing shown above. &lt;a href=&quot;https://restic.readthedocs.io/en/v0.19.1/030_preparing_a_new_repo.html&quot;&gt;restic repository setup&lt;/a&gt; · &lt;a href=&quot;https://developers.cloudflare.com/r2/buckets/storage-classes/&quot;&gt;R2 storage classes&lt;/a&gt;&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Provider&lt;/th&gt;
&lt;th&gt;Example value for &lt;code&gt;RESTIC_REPOSITORY&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;Credentials&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Backblaze B2&lt;/td&gt;
&lt;td&gt;&lt;code&gt;s3:https://s3.us-west-002.backblazeb2.com/BUCKET&lt;/code&gt;. Use the endpoint shown for your own bucket.&lt;/td&gt;
&lt;td&gt;Set the application key&apos;s &lt;code&gt;keyID&lt;/code&gt; as the access key ID and &lt;code&gt;applicationKey&lt;/code&gt; as the secret. &lt;a href=&quot;https://www.backblaze.com/docs/cloud-storage-integrate-restic-with-backblaze-b2&quot;&gt;Backblaze restic setup&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wasabi&lt;/td&gt;
&lt;td&gt;&lt;code&gt;s3:https://s3.wasabisys.com/BUCKET&lt;/code&gt; for US East 1. Use the service URL for your bucket&apos;s region.&lt;/td&gt;
&lt;td&gt;Use the access key created for your Wasabi user account. &lt;a href=&quot;https://docs.wasabi.com/docs/service-urls-for-wasabis-storage-regions&quot;&gt;Wasabi endpoints&lt;/a&gt; · &lt;a href=&quot;https://docs.wasabi.com/docs/getting-started&quot;&gt;Wasabi setup&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hetzner&lt;/td&gt;
&lt;td&gt;&lt;code&gt;s3:https://fsn1.your-objectstorage.com/BUCKET&lt;/code&gt; for Falkenstein. Set &lt;code&gt;AWS_DEFAULT_REGION&lt;/code&gt; to &lt;code&gt;fsn1&lt;/code&gt; for this example.&lt;/td&gt;
&lt;td&gt;Use the Hetzner S3 access and secret keys. &lt;a href=&quot;https://docs.hetzner.com/storage/object-storage/howto-backups/restic/&quot;&gt;Hetzner restic setup&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cloudflare R2&lt;/td&gt;
&lt;td&gt;&lt;code&gt;s3:https://ACCOUNT_ID.r2.cloudflarestorage.com/BUCKET&lt;/code&gt;. Set &lt;code&gt;AWS_DEFAULT_REGION&lt;/code&gt; to &lt;code&gt;auto&lt;/code&gt;. For a bucket with a jurisdiction, use its corresponding endpoint.&lt;/td&gt;
&lt;td&gt;Create an R2 API token with Object Read &amp;amp; Write scoped to the bucket. Use the resulting access key ID and secret access key. &lt;a href=&quot;https://developers.cloudflare.com/r2/api/tokens/&quot;&gt;R2 authentication&lt;/a&gt; · &lt;a href=&quot;https://developers.cloudflare.com/r2/api/s3/api/&quot;&gt;R2 S3 compatibility&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Use the selected endpoint and bucket in the following settings. Save them in &lt;code&gt;/etc/restic-env&lt;/code&gt; and restrict access to the account running restic. Store the repository password in &lt;code&gt;/etc/restic-password&lt;/code&gt; with the same access restriction. Keep the repository password available for recovery, which requires it. &lt;a href=&quot;https://www.backblaze.com/docs/cloud-storage-integrate-restic-with-backblaze-b2&quot;&gt;Backblaze restic setup&lt;/a&gt; · &lt;a href=&quot;https://restic.readthedocs.io/en/v0.19.1/030_preparing_a_new_repo.html&quot;&gt;restic repository setup&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;export AWS_ACCESS_KEY_ID=&apos;YOUR_ACCESS_KEY_ID&apos;
export AWS_SECRET_ACCESS_KEY=&apos;YOUR_SECRET_ACCESS_KEY&apos;
export RESTIC_REPOSITORY=&apos;s3:https://YOUR_ENDPOINT/YOUR_BUCKET&apos;
export RESTIC_PASSWORD_FILE=&apos;/etc/restic-password&apos;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For the Hetzner or R2 examples, also export the corresponding &lt;code&gt;AWS_DEFAULT_REGION&lt;/code&gt; value in that file. &lt;a href=&quot;https://restic.readthedocs.io/en/v0.19.1/030_preparing_a_new_repo.html&quot;&gt;restic repository setup&lt;/a&gt; · &lt;a href=&quot;https://docs.hetzner.com/storage/object-storage/howto-backups/restic/&quot;&gt;Hetzner restic setup&lt;/a&gt; · &lt;a href=&quot;https://developers.cloudflare.com/r2/api/s3/api/&quot;&gt;R2 S3 compatibility&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Back up a sample and restore it separately&lt;/h2&gt;
&lt;p&gt;Replace &lt;code&gt;/path/to/nas/sample&lt;/code&gt; with a small folder you can read. Run &lt;code&gt;restic init&lt;/code&gt; once for the new repository. Check that &lt;code&gt;restic snapshots&lt;/code&gt; lists the expected folder before restoring. &lt;a href=&quot;https://www.backblaze.com/docs/cloud-storage-integrate-restic-with-backblaze-b2&quot;&gt;Backblaze restic setup&lt;/a&gt; · &lt;a href=&quot;https://restic.readthedocs.io/en/v0.19.1/030_preparing_a_new_repo.html&quot;&gt;restic repository setup&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;source /etc/restic-env
restic init
restic backup /path/to/nas/sample
restic snapshots
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Choose a new, empty restore target. Restic can overwrite existing files in the target directory. In this new repository, &lt;code&gt;latest&lt;/code&gt; selects the snapshot you just made. For the example source path, open the restored files under &lt;code&gt;/tmp/nas-restore-sample/path/to/nas/sample&lt;/code&gt; and compare them with the originals. &lt;a href=&quot;https://restic.readthedocs.io/en/v0.19.1/050_restore.html&quot;&gt;restic restore docs&lt;/a&gt; · &lt;a href=&quot;https://www.backblaze.com/docs/cloud-storage-integrate-restic-with-backblaze-b2&quot;&gt;Backblaze restic setup&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;restic restore latest --target /tmp/nas-restore-sample
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Evidence and limits.&lt;/strong&gt; Provider pricing and S3 documentation were checked on November 26, 2026. The workflow uses the restic 0.19.1 documentation. The commands were not run for this article.&lt;/p&gt;
</content:encoded><category>nas</category><category>cloud-backup</category><category>object-storage</category><category>restic</category><author>Homelab Backup Editorial</author></item><item><title>Homelab 3-2-1 Backup Architecture for VMs and NAS</title><link>https://homelabbackup.com/posts/homelab-3-2-1-backup-architecture-vms-nas/</link><guid isPermaLink="true">https://homelabbackup.com/posts/homelab-3-2-1-backup-architecture-vms-nas/</guid><description>Build a 3-2-1 backup plan for Proxmox VMs, TrueNAS datasets, and Docker apps with a separate NAS, an offsite copy, and a restore drill.</description><pubDate>Thu, 26 Nov 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Use a separate backup NAS for Proxmox VM archives, replicated TrueNAS datasets, and Docker app backups. Send those backups to offsite cloud storage. That gives each workload three copies across local disk and cloud storage, with one copy offsite. &lt;a href=&quot;https://www.backblaze.com/learning-center/3-2-1-backup-strategy&quot;&gt;Backblaze&apos;s local and cloud example&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Map the three copies&lt;/h2&gt;
&lt;p&gt;In this example, a dedicated TrueNAS system holds the local backups and sends them to Storj through TrueCloud Backup. Keep snapshots on the primary TrueNAS to recover older or deleted files. Those snapshots share storage with the live dataset, so count the replica on the backup NAS as the local backup. &lt;a href=&quot;https://www.truenas.com/docs/scale/25.10/scaletutorials/dataprotection/periodicsnapshottasksscale/&quot;&gt;TrueNAS snapshot behavior&lt;/a&gt; &lt;a href=&quot;https://www.truenas.com/docs/scale/25.10/scaletutorials/dataprotection/replication/remotereplicationscale/&quot;&gt;TrueNAS remote replication&lt;/a&gt; &lt;a href=&quot;https://www.truenas.com/docs/scale/25.10/scaletutorials/dataprotection/truecloudtasks/&quot;&gt;TrueCloud backup tasks&lt;/a&gt;&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Workload&lt;/th&gt;
&lt;th&gt;Live copy&lt;/th&gt;
&lt;th&gt;Separate backup NAS&lt;/th&gt;
&lt;th&gt;Offsite cloud copy&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Proxmox VM&lt;/td&gt;
&lt;td&gt;Guest disks and VM configuration&lt;/td&gt;
&lt;td&gt;&lt;code&gt;vzdump&lt;/code&gt; archives in the VM backup dataset&lt;/td&gt;
&lt;td&gt;TrueCloud backups of the archive dataset&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TrueNAS&lt;/td&gt;
&lt;td&gt;Live file datasets and active NAS configuration&lt;/td&gt;
&lt;td&gt;Replicated datasets and a protected configuration export&lt;/td&gt;
&lt;td&gt;TrueCloud backups of the replicated files and configuration export&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Docker app on Linux&lt;/td&gt;
&lt;td&gt;Deployment files, persistent data, and any database&lt;/td&gt;
&lt;td&gt;Deployment files, volume archives or bind-mount files, and database dumps&lt;/td&gt;
&lt;td&gt;TrueCloud backups of the Docker backup dataset&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;When a VM or container uses files from a TrueNAS share, put those files in the TrueNAS row. Include each dataset that holds shared files. An NFS export serves the selected dataset, and NFS treats child datasets as separate filesystems. &lt;a href=&quot;https://github.com/proxmox/pve-docs/blob/master/vzdump.adoc&quot;&gt;Proxmox VE backup guide&lt;/a&gt; &lt;a href=&quot;https://www.truenas.com/docs/scale/25.10/scaletutorials/shares/addingnfsshares/&quot;&gt;TrueNAS NFS shares&lt;/a&gt; &lt;a href=&quot;https://docs.docker.com/engine/storage/volumes/&quot;&gt;Docker volume guide&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Back up Proxmox VMs to the backup NAS&lt;/h2&gt;
&lt;p&gt;On the backup NAS, go to &lt;strong&gt;Shares → Unix (NFS) Shares → Add&lt;/strong&gt;. Select a child dataset for VM archives. Restrict &lt;strong&gt;Allowed Hosts&lt;/strong&gt; to the Proxmox host. Under &lt;strong&gt;Advanced Options&lt;/strong&gt;, clear &lt;strong&gt;Read-Only&lt;/strong&gt; and use &lt;strong&gt;Maproot User&lt;/strong&gt; to map client root to a local account that can write to the archive dataset. Save the share and select &lt;strong&gt;Enable Service&lt;/strong&gt; if prompted. &lt;a href=&quot;https://www.truenas.com/docs/scale/25.10/scaletutorials/shares/addingnfsshares/&quot;&gt;TrueNAS NFS setup&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;On Proxmox VE, substitute your backup NAS address, export path, and VM ID. Snapshot mode copies VM blocks while the guest runs, with a small risk of inconsistency. For recurring runs, open &lt;strong&gt;Datacenter → Backup&lt;/strong&gt;, select the VM and &lt;code&gt;backup-nas&lt;/code&gt; storage, and set the schedule and retention. &lt;a href=&quot;https://github.com/proxmox/pve-docs/blob/master/pvesm.adoc&quot;&gt;Proxmox storage commands&lt;/a&gt; &lt;a href=&quot;https://github.com/proxmox/pve-docs/blob/master/pve-storage-nfs.adoc&quot;&gt;NFS storage settings&lt;/a&gt; &lt;a href=&quot;https://github.com/proxmox/pve-docs/blob/master/generated/vzdump.1-synopsis.adoc?plain=1&quot;&gt;vzdump options&lt;/a&gt; &lt;a href=&quot;https://github.com/proxmox/pve-docs/blob/master/vzdump.adoc&quot;&gt;Backup modes and schedules&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;pvesm add nfs backup-nas --path /mnt/pve/backup-nas \
  --server 192.0.2.10 --export /mnt/backup/vm-archives --content backup
vzdump 777 --storage backup-nas --mode snapshot
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Replicate TrueNAS data and save its configuration&lt;/h2&gt;
&lt;p&gt;This example uses TrueNAS 25.10 on both NAS systems. Give the administrator accounts on both systems home directories. On the backup NAS, go to &lt;strong&gt;Credentials → Users&lt;/strong&gt;, edit the replication administrator, and enable &lt;strong&gt;SSH Access&lt;/strong&gt;. Under &lt;strong&gt;Sudo Commands&lt;/strong&gt;, select &lt;strong&gt;Allow all sudo commands with no password&lt;/strong&gt; and save. In &lt;strong&gt;System → Services → SSH&lt;/strong&gt;, edit the service, enable &lt;strong&gt;Allow Password Authentication&lt;/strong&gt;, and save. Start or restart SSH.&lt;/p&gt;
&lt;p&gt;On the primary NAS, go to &lt;strong&gt;Credentials → Backup Credentials → SSH Connections&lt;/strong&gt; and click &lt;strong&gt;Add&lt;/strong&gt;. Name the connection and set &lt;strong&gt;Setup Method&lt;/strong&gt; to &lt;strong&gt;Semi-Automatic&lt;/strong&gt;. Enter the backup NAS address as a URL in &lt;strong&gt;TrueNAS URL&lt;/strong&gt;. Fill in &lt;strong&gt;Admin Username&lt;/strong&gt; and &lt;strong&gt;Admin Password&lt;/strong&gt; with the credentials for the remote web UI. Enter the backup NAS replication administrator&apos;s username for the SSH session. In &lt;strong&gt;Private Key&lt;/strong&gt;, select &lt;strong&gt;Generate New&lt;/strong&gt;, then click &lt;strong&gt;Save&lt;/strong&gt;. Back in &lt;strong&gt;SSH Connections&lt;/strong&gt;, click &lt;strong&gt;Edit&lt;/strong&gt; on the new connection and copy its public key. On the backup NAS, edit the replication administrator, paste the key into &lt;strong&gt;Public SSH Key&lt;/strong&gt;, and save. &lt;a href=&quot;https://www.truenas.com/docs/scale/25.10/scaletutorials/dataprotection/replication/remotereplicationscale/&quot;&gt;TrueNAS replication prerequisites&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;On the backup NAS, go to &lt;strong&gt;Datasets&lt;/strong&gt; and create the receiving dataset before opening the replication wizard. On the primary NAS, go to &lt;strong&gt;Data Protection → Replication&lt;/strong&gt; and click &lt;strong&gt;Add&lt;/strong&gt;. Set &lt;strong&gt;Source Location&lt;/strong&gt; to &lt;strong&gt;On this System&lt;/strong&gt; and &lt;strong&gt;Destination Location&lt;/strong&gt; to &lt;strong&gt;On a Different System&lt;/strong&gt;. Select the SSH connection and choose the primary dataset and its destination on the backup NAS. When setting up replication as an administrator, enable &lt;strong&gt;Use Sudo for ZFS Commands&lt;/strong&gt;. If a confirmation dialog opens, click &lt;strong&gt;Use Sudo for ZFS Commands&lt;/strong&gt; in the dialog. Use a destination with no existing snapshots or back up any destination snapshots with critical data before creating the task. &lt;a href=&quot;https://www.truenas.com/docs/scale/25.10/scaletutorials/dataprotection/replication/remotereplicationscale/&quot;&gt;TrueNAS replication wizard&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Click &lt;strong&gt;Next&lt;/strong&gt; after choosing the source and destination settings. Set &lt;strong&gt;Replication Schedule&lt;/strong&gt; and &lt;strong&gt;Destination Snapshot Lifetime&lt;/strong&gt;, save, and select &lt;strong&gt;Run Now&lt;/strong&gt;. On the backup NAS, select the receiving dataset in &lt;strong&gt;Datasets&lt;/strong&gt; and open &lt;strong&gt;Manage Snapshots&lt;/strong&gt; to confirm that the expected snapshot arrived. The wizard creates a periodic snapshot task for local sources that have no existing snapshots. &lt;a href=&quot;https://www.truenas.com/docs/scale/25.10/scaletutorials/dataprotection/replication/remotereplicationscale/&quot;&gt;TrueNAS replication schedules and snapshot checks&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;On the primary NAS, sign in as a system administrator with full administrative access and go to &lt;strong&gt;System → Advanced Settings → Manage Configuration → Download File&lt;/strong&gt;. In the &lt;strong&gt;Save Configuration&lt;/strong&gt; dialog, select &lt;strong&gt;Export Password Secret Seed&lt;/strong&gt;, then click &lt;strong&gt;Save&lt;/strong&gt; to download the export. Store it in protected backup storage. Secure it alongside any keys needed to unlock encrypted datasets. Repeat the export after configuration changes. &lt;a href=&quot;https://cdn.truenas.com/docs/scale/25.10/scaletutorials/systemsettings/advanced/managesysconfig/&quot;&gt;TrueNAS configuration backup guide&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Back up Docker configuration and app data&lt;/h2&gt;
&lt;p&gt;On the backup NAS, go to &lt;strong&gt;Shares → Unix (NFS) Shares → Add&lt;/strong&gt; and select a separate dataset for Docker backups, such as &lt;code&gt;/mnt/backup/docker-backups&lt;/code&gt;. If the dataset does not exist, click &lt;strong&gt;Create Dataset&lt;/strong&gt;, enter its name, and click &lt;strong&gt;Create&lt;/strong&gt;. Under &lt;strong&gt;Allowed Hosts&lt;/strong&gt;, click &lt;strong&gt;Add&lt;/strong&gt; and enter the Docker host’s address or host name. In &lt;strong&gt;Advanced Options&lt;/strong&gt;, clear &lt;strong&gt;Read-Only&lt;/strong&gt; and use &lt;strong&gt;Mapall User&lt;/strong&gt; to map requests to a local account with write access to the dataset. Save the share and select &lt;strong&gt;Enable Service&lt;/strong&gt; if prompted. If NFS is still off, start it under &lt;strong&gt;System → Services&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;On the Linux Docker host, install the NFS client package with your distribution&apos;s package manager. On Ubuntu or Debian, run &lt;code&gt;sudo apt-get install nfs-common&lt;/code&gt;. Mount the export at an existing local directory using the command below, substituting your NAS address, export path, and mount point. Once the mount succeeds, use the mounted directory for the Docker archive and PostgreSQL dump. &lt;a href=&quot;https://www.truenas.com/docs/scale/25.10/scaletutorials/shares/addingnfsshares/&quot;&gt;TrueNAS NFS client setup&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo mount -t nfs 192.0.2.10:/mnt/backup/docker-backups /mnt/docker-backups
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Save the Compose file and any environment files it references. For each persistent mount, identify the Docker volume or host-side directory. For a bind mount, copy the host-side source files to the backup NAS. If the source files live on a TrueNAS share, cover them through dataset replication. During recovery, put bind-mount files at the configured source paths on the host running the Docker daemon. Restore each referenced &lt;code&gt;env_file&lt;/code&gt; at its specified path relative to the restored Compose file. &lt;a href=&quot;https://docs.docker.com/compose/how-tos/environment-variables/set-environment-variables/&quot;&gt;Compose environment files&lt;/a&gt; &lt;a href=&quot;https://docs.docker.com/engine/storage/bind-mounts/&quot;&gt;Docker bind mounts&lt;/a&gt; &lt;a href=&quot;https://docs.docker.com/engine/storage/volumes/&quot;&gt;Docker volumes&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;For this file-only example, the container &lt;code&gt;dbstore&lt;/code&gt; already has a volume mounted at &lt;code&gt;/dbdata&lt;/code&gt;, and its writers are stopped. On the Docker host, run the archive command from the backup directory on the NAS share. &lt;a href=&quot;https://docs.docker.com/engine/storage/volumes/&quot;&gt;Docker volume backup example&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;docker run --rm --volumes-from dbstore -v &amp;quot;$(pwd):/backup&amp;quot; \
  ubuntu tar cvf /backup/backup.tar /dbdata
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For a simple PostgreSQL app, use a database-native dump. On the Docker host, use PostgreSQL client tools that can connect and authenticate to the app’s PostgreSQL server. In the shell running the dump, export &lt;code&gt;PGHOST&lt;/code&gt;, &lt;code&gt;PGPORT&lt;/code&gt;, and &lt;code&gt;PGUSER&lt;/code&gt; for the server address, port, and a database user with read access to every table being backed up. Run &lt;code&gt;pg_dump appdb &amp;gt; appdb.sql&lt;/code&gt; in the backup directory. This exports one database at a consistent point in time. Preserve the database roles separately if recovery requires them. &lt;a href=&quot;https://www.postgresql.org/docs/18/backup-dump.html&quot;&gt;PostgreSQL SQL dump and restore&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Send the backup NAS data offsite&lt;/h2&gt;
&lt;p&gt;In the Storj iX dashboard, go to &lt;strong&gt;Access Keys → New Access Key&lt;/strong&gt;, name the key, select &lt;strong&gt;S3 Credentials&lt;/strong&gt;, and click &lt;strong&gt;Next&lt;/strong&gt;. To let TrueNAS create the bucket, choose &lt;strong&gt;Full Access&lt;/strong&gt; and click &lt;strong&gt;Create Access&lt;/strong&gt;. Use &lt;strong&gt;Copy All&lt;/strong&gt; or &lt;strong&gt;Download All&lt;/strong&gt; to obtain the access key, secret key, and endpoint. Under &lt;strong&gt;Credentials → Backup Credentials&lt;/strong&gt;, click &lt;strong&gt;Add&lt;/strong&gt; on &lt;strong&gt;Cloud Credentials&lt;/strong&gt;. Enter a descriptive &lt;strong&gt;Name&lt;/strong&gt; and fill in &lt;strong&gt;Access Key ID&lt;/strong&gt; and &lt;strong&gt;Secret Access Key&lt;/strong&gt;. Click &lt;strong&gt;Verify Credentials&lt;/strong&gt;, wait for verification, and click &lt;strong&gt;Save&lt;/strong&gt;. Go to &lt;strong&gt;Data Protection → TrueCloud Backup Tasks → Add&lt;/strong&gt; and select the saved Storj credential. Under &lt;strong&gt;Bucket&lt;/strong&gt;, choose &lt;strong&gt;Add New&lt;/strong&gt; and enter a name using only lowercase letters, numbers, and hyphens. TrueNAS creates the compatible bucket when you save the task. Set up a task for each protected path and give each task its own bucket folder. In &lt;strong&gt;Folder&lt;/strong&gt;, enter &lt;code&gt;/name&lt;/code&gt; to create a folder that does not exist, replacing &lt;code&gt;name&lt;/code&gt; with the folder name. &lt;a href=&quot;https://www.truenas.com/docs/scale/25.10/scaletutorials/dataprotection/truecloudtasks/&quot;&gt;TrueCloud credentials and task setup&lt;/a&gt;&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Setting&lt;/th&gt;
&lt;th&gt;What to enter in this example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Source Path&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;VM backup dataset exported over NFS, a replicated file dataset, or a protected Docker or NAS configuration backup directory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Storj credential, &lt;strong&gt;Bucket&lt;/strong&gt;, &lt;strong&gt;Folder&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Saved credential, compatible bucket, and a folder for that source&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Keep Last&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Number of recovery points the task should retain&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Password&lt;/strong&gt; and &lt;strong&gt;Schedule&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Repository password and a schedule after the local copy is ready&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;For the VM archive task, leave &lt;strong&gt;Use Absolute Paths&lt;/strong&gt; clear under &lt;strong&gt;Advanced Options&lt;/strong&gt; to store relative paths. Keep &lt;strong&gt;Enabled&lt;/strong&gt; selected for scheduled runs. Enter a name under &lt;strong&gt;Task Settings&lt;/strong&gt; and click &lt;strong&gt;Save&lt;/strong&gt;. After the VM archive and Docker files are complete and the NAS replica has arrived, open the saved task’s three-dot menu, select &lt;strong&gt;Run Job&lt;/strong&gt;, and check for &lt;strong&gt;SUCCESS&lt;/strong&gt;. Store the cloud credential, bucket and folder names, and repository password somewhere you can reach if the local NAS is lost. &lt;a href=&quot;https://www.truenas.com/docs/scale/25.10/scaletutorials/dataprotection/truecloudtasks/&quot;&gt;TrueCloud task status and repository recovery&lt;/a&gt; &lt;a href=&quot;https://www.truenas.com/docs/scale/25.10/scaleuireference/dataprotection/truecloudbackuptasksscreen/&quot;&gt;TrueCloud path and schedule settings&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Rehearse recovery from both destinations&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;VM.&lt;/strong&gt; On Proxmox, use &lt;code&gt;pvesm list backup-nas --vmid 777&lt;/code&gt; to find the archive and &lt;code&gt;pvesm path&lt;/code&gt; with its volume ID to get the file path. Set &lt;code&gt;archive&lt;/code&gt; to that path. Use a Proxmox test setup where the restored guest will boot on a network isolated from the original VM and other live guests. Confirm that isolation before running &lt;code&gt;qmrestore &amp;quot;$archive&amp;quot; 601 --storage restore-storage --start 1&lt;/code&gt;, using an unused VM ID and the ID of a storage that accepts VM disks. Proxmox starts the VM after a successful restore. Confirm the guest boots by signing in, then open a known guest file or check that a known service responds. &lt;a href=&quot;https://github.com/proxmox/pve-docs/blob/master/pvesm.adoc&quot;&gt;Proxmox archive lookup and storage content types&lt;/a&gt; &lt;a href=&quot;https://github.com/proxmox/pve-docs/blob/master/generated/qmrestore.1-synopsis.adoc&quot;&gt;qmrestore options&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;NAS file.&lt;/strong&gt; On the backup NAS, open &lt;strong&gt;Datasets → Manage Snapshots&lt;/strong&gt; for the replica. Expand the snapshot and select &lt;strong&gt;Clone to New Dataset&lt;/strong&gt;. In the confirmation dialog, click &lt;strong&gt;Clone&lt;/strong&gt;. Use the TrueNAS NFS share steps above to export the clone by its own dataset path. A parent NFS share does not expose child datasets. Under &lt;strong&gt;Allowed Hosts&lt;/strong&gt;, specify the Linux verification host. In &lt;strong&gt;Advanced Options&lt;/strong&gt;, select &lt;strong&gt;Read-Only&lt;/strong&gt;, then save the share. Use the Linux mount command above with the clone export path and an existing local mount point. Once the mount succeeds, open a known file through it. Avoid rolling back the original dataset for this drill because rollback can destroy newer data and snapshots. &lt;a href=&quot;https://www.truenas.com/docs/scale/25.10/scaleuireference/datasets/snapshotsscreens/&quot;&gt;TrueNAS clone and rollback controls&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Docker volume.&lt;/strong&gt; From the directory with &lt;code&gt;backup.tar&lt;/code&gt;, set &lt;code&gt;restore_container&lt;/code&gt; to an unused container name for this run. Extract the archive only after Docker successfully creates the new container. Use the same name for &lt;code&gt;--name&lt;/code&gt; and &lt;code&gt;--volumes-from&lt;/code&gt;. In the &lt;code&gt;docker inspect&lt;/code&gt; output, confirm that the volume entry under &lt;code&gt;Mounts&lt;/code&gt; has &lt;code&gt;Destination&lt;/code&gt; set to &lt;code&gt;/dbdata&lt;/code&gt;. The last command opens a shell in a temporary container that mounts the recovered volume. Open a known recovered file under &lt;code&gt;/dbdata&lt;/code&gt; inside that container. For PostgreSQL, confirm that both &lt;code&gt;createdb&lt;/code&gt; and &lt;code&gt;psql&lt;/code&gt; are configured to connect and authenticate to the intended scratch server. Choose an unused scratch database name and substitute it for &lt;code&gt;local_scratch_name&lt;/code&gt; in both commands. From the directory containing the local &lt;code&gt;appdb.sql&lt;/code&gt;, run &lt;code&gt;createdb -T template0 local_scratch_name&lt;/code&gt;. Proceed only if it succeeds. To restore original ownership and permissions, ensure the users who owned objects or had permissions on them exist before running &lt;code&gt;psql -X --set ON_ERROR_STOP=on local_scratch_name &amp;lt; appdb.sql&lt;/code&gt;. Check for expected records only after the import succeeds. &lt;a href=&quot;https://docs.docker.com/engine/storage/volumes/&quot;&gt;Docker volume restore example&lt;/a&gt; &lt;a href=&quot;https://www.postgresql.org/docs/18/backup-dump.html&quot;&gt;PostgreSQL restore procedure&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;restore_container=volume-restore-local
docker run -v /dbdata --name &amp;quot;$restore_container&amp;quot; ubuntu /bin/bash &amp;amp;&amp;amp;
  docker run --rm --volumes-from &amp;quot;$restore_container&amp;quot; -v &amp;quot;$(pwd):/backup&amp;quot; \
    ubuntu bash -c &amp;quot;cd /dbdata &amp;amp;&amp;amp; tar xvf /backup/backup.tar --strip 1&amp;quot; &amp;amp;&amp;amp;
  docker inspect &amp;quot;$restore_container&amp;quot; &amp;amp;&amp;amp;
  docker run -it --rm --volumes-from &amp;quot;$restore_container&amp;quot; ubuntu bash
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Repeat the checks with cloud data. On a replacement TrueNAS, configure a local pool and dataset before recreating the tasks. Follow the credential steps above to re-add the Storj credential from the saved S3 keys. Click &lt;strong&gt;Verify Credentials&lt;/strong&gt; and save the verified credential before selecting it in the recreated tasks. Set each task’s &lt;strong&gt;Source Path&lt;/strong&gt; to an existing local dataset or directory and use the saved bucket, folders, and repository passwords. Leave &lt;strong&gt;Enabled&lt;/strong&gt; clear while recovering. Enter a task name and click &lt;strong&gt;Save&lt;/strong&gt;. In the recreated task’s menu, choose &lt;strong&gt;View Details&lt;/strong&gt;, then select the recreated task to open its &lt;strong&gt;Snapshots&lt;/strong&gt; widget. Select &lt;strong&gt;Restore&lt;/strong&gt; for the chosen snapshot and choose &lt;strong&gt;Include Everything&lt;/strong&gt;. In the &lt;strong&gt;Target&lt;/strong&gt; picker, browse to the parent dataset, click &lt;strong&gt;Create Dataset&lt;/strong&gt;, and name and create a fresh dataset. Select the new dataset as &lt;strong&gt;Target&lt;/strong&gt;, then click &lt;strong&gt;Save&lt;/strong&gt; to start the restore. Repeat for each protected path, using a separate fresh target dataset for each. Wait for each restore to finish before opening files or exporting its dataset. For the restored NAS files, reuse the NFS share and Linux mount steps from the clone drill. Export each restored file dataset by its own path as a &lt;strong&gt;Read-Only&lt;/strong&gt; NFS share restricted to the Linux verification host. Mount that export on the verification host and open a known restored file through the mount. &lt;a href=&quot;https://www.truenas.com/docs/scale/25.10/scaleuireference/dataprotection/truecloudbackuptasksscreen/&quot;&gt;TrueCloud restore controls&lt;/a&gt; &lt;a href=&quot;https://www.truenas.com/docs/scale/25.10/scaletutorials/dataprotection/truecloudtasks/&quot;&gt;TrueCloud restore procedure&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Export the recovered VM archive dataset over NFS. Use the recovered dataset root that keeps each archive at the same path relative to the export as before. If the NAS address or export path changed, repeat the &lt;code&gt;pvesm add nfs&lt;/code&gt; command above with an unused storage ID such as &lt;code&gt;backup-nas-recovery&lt;/code&gt;, its own local mount path, and the recovered export’s address and path. In that case, use &lt;code&gt;pvesm list backup-nas-recovery --vmid 777&lt;/code&gt; for archive lookup in the VM drill. Repeat the VM drill with the same network isolation before boot. Use an unused VM ID in the cloud drill, different from the local drill’s ID if its test VM still exists.&lt;/p&gt;
&lt;p&gt;Export the recovered Docker dataset and mount it on the Docker host using the Docker NFS procedure above. Substitute the replacement NAS address, recovered export path, and a separate local mount point. Repeat the Docker drill from the mounted directory with the recovered files. Set &lt;code&gt;restore_container&lt;/code&gt; to an unused container name for the cloud run. For PostgreSQL, work from the directory containing the recovered &lt;code&gt;appdb.sql&lt;/code&gt;. As in the local drill, confirm that both &lt;code&gt;createdb&lt;/code&gt; and &lt;code&gt;psql&lt;/code&gt; are configured to connect and authenticate to the intended scratch server. Choose an unused scratch database name different from the local drill’s and substitute it for &lt;code&gt;cloud_scratch_name&lt;/code&gt; in both commands. Run &lt;code&gt;createdb -T template0 cloud_scratch_name&lt;/code&gt; and proceed only if it succeeds. With the required roles in place, run &lt;code&gt;psql -X --set ON_ERROR_STOP=on cloud_scratch_name &amp;lt; appdb.sql&lt;/code&gt;. Check for expected records only after the import succeeds. &lt;a href=&quot;https://www.truenas.com/docs/scale/25.10/scaletutorials/shares/addingnfsshares/&quot;&gt;TrueNAS NFS setup&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Evidence and limits.&lt;/strong&gt; Checked November 26, 2026 against TrueNAS 25.10, PostgreSQL 18, and the rolling Proxmox VE and Docker documentation. The backup and restore steps were not run for this article.&lt;/p&gt;
</content:encoded><category>backup</category><category>proxmox</category><category>truenas</category><category>docker</category><category>disaster-recovery</category><author>Homelab Backup Editorial</author></item><item><title>Proxmox Backup Server Prune, Garbage Collection, and Verify</title><link>https://homelabbackup.com/posts/proxmox-backup-server-prune-garbage-collect-verify/</link><guid isPermaLink="true">https://homelabbackup.com/posts/proxmox-backup-server-prune-garbage-collect-verify/</guid><description>Preview Proxmox Backup Server retention, schedule garbage collection and verification, and find out why disk space can stay in use after pruning.</description><pubDate>Thu, 26 Nov 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;In Proxmox Backup Server (PBS), &lt;strong&gt;prune&lt;/strong&gt; applies your retention rules and removes the metadata for snapshots it selects for deletion. &lt;strong&gt;Garbage collection (GC)&lt;/strong&gt; reclaims storage by removing eligible unused data chunks. &lt;strong&gt;Verify&lt;/strong&gt; checks whether backup data is intact. For space reclamation, prune first and let GC clean up after it. Schedule verification to check the backups you keep. &lt;a href=&quot;https://pbs.proxmox.com/docs/maintenance.html&quot;&gt;Proxmox maintenance tasks&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Preview retention and schedule pruning&lt;/h2&gt;
&lt;p&gt;Start with a dry run on a backup group. This example uses the group &lt;code&gt;host/elsa&lt;/code&gt; and the repository &lt;code&gt;backup-server:store1&lt;/code&gt;. Replace both with your own values. The dry run shows what pruning would keep or remove without deleting snapshots. &lt;a href=&quot;https://pbs.proxmox.com/docs/backup-client.html&quot;&gt;Proxmox backup client guide&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;proxmox-backup-client prune host/elsa --repository backup-server:store1 \
  --dry-run --keep-daily 1 --keep-weekly 3
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Review the &lt;code&gt;keep&lt;/code&gt; column for the recovery points you need. A &lt;code&gt;1&lt;/code&gt; marks a snapshot to keep and a &lt;code&gt;0&lt;/code&gt; marks one to remove. The weekly rule considers older backups outside the period already covered by the daily rule. Days and weeks without backups do not count toward their respective rules. &lt;a href=&quot;https://pbs.proxmox.com/docs/backup-client.html#pruning-and-removing-backups&quot;&gt;Proxmox dry-run example&lt;/a&gt; · &lt;a href=&quot;https://pbs.proxmox.com/docs/maintenance.html#pruning&quot;&gt;Proxmox retention rules&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Before enabling pruning&lt;/strong&gt;, choose retention values that match the recovery points you need. Preview those same values on every group the job will cover. Live pruning removes the selected snapshots’ metadata. The job below targets the &lt;code&gt;store1&lt;/code&gt; datastore. The &lt;code&gt;--max-depth 0&lt;/code&gt; option keeps it from descending into child namespaces. Use &lt;code&gt;--ns&lt;/code&gt; on both the preview and the job when targeting a named namespace. &lt;a href=&quot;https://pbs.proxmox.com/docs/maintenance.html#prune-jobs&quot;&gt;Proxmox prune jobs&lt;/a&gt; · &lt;a href=&quot;https://pbs.proxmox.com/docs/command-syntax.html&quot;&gt;Proxmox command syntax&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Run the manager command on the PBS host once you have confirmed the scope and retention settings. The example schedules pruning at midnight each day in the server’s time zone. &lt;a href=&quot;https://pbs.proxmox.com/docs/command-syntax.html&quot;&gt;Proxmox command syntax&lt;/a&gt; · &lt;a href=&quot;https://pbs.proxmox.com/docs/calendarevents.html&quot;&gt;Proxmox calendar events&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;proxmox-backup-manager prune-job create root-retention --store store1 \
  --schedule daily --max-depth 0 --keep-daily 1 --keep-weekly 3
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Run and schedule garbage collection&lt;/h2&gt;
&lt;p&gt;Pruning can remove snapshots while the chunks they used still take up space. If a retained snapshot references a chunk, GC keeps it. GC also leaves chunks within the access-time grace period in place and reports them as &lt;strong&gt;Pending removals&lt;/strong&gt; in the task log. &lt;a href=&quot;https://pbs.proxmox.com/docs/maintenance.html#garbage-collection&quot;&gt;Proxmox garbage collection&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Without an active backup writer, the default cutoff is 24 hours and 5 minutes before GC starts. An active backup writer can affect the cutoff. Eligibility depends on a chunk’s access time, so the time since the prune job ended alone cannot tell you when a chunk becomes eligible. If the log shows &lt;strong&gt;Pending removals&lt;/strong&gt;, check the results of a later GC run. &lt;a href=&quot;https://pbs.proxmox.com/docs/maintenance.html#garbage-collection&quot;&gt;Proxmox garbage collection&lt;/a&gt; · &lt;a href=&quot;https://pbs.proxmox.com/docs/configuration-files.html&quot;&gt;Proxmox datastore tuning&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;After pruning, you can start GC manually for &lt;code&gt;store1&lt;/code&gt; and query its status with the following commands. In the web interface, use &lt;strong&gt;Start Garbage Collection&lt;/strong&gt; in the datastore’s &lt;strong&gt;Prune &amp;amp; GC&lt;/strong&gt; tab to start it. &lt;a href=&quot;https://pbs.proxmox.com/docs/maintenance.html#manually-starting-gc&quot;&gt;Proxmox garbage collection&lt;/a&gt; · &lt;a href=&quot;https://pbs.proxmox.com/docs/command-syntax.html&quot;&gt;Proxmox command syntax&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;proxmox-backup-manager garbage-collection start store1
proxmox-backup-manager garbage-collection status store1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To read the run’s log, list server tasks including completed runs. Copy the GC run’s unique task ID (UPID) and replace &lt;code&gt;TASK_ID&lt;/code&gt; with it. &lt;a href=&quot;https://pbs.proxmox.com/docs/command-syntax.html&quot;&gt;Proxmox command syntax&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;proxmox-backup-manager task list --all true
proxmox-backup-manager task log &apos;TASK_ID&apos;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Set a recurring GC schedule so later runs can pick up newly eligible chunks. This example schedules GC for Saturday at 03:00 in the server’s time zone. &lt;a href=&quot;https://pbs.proxmox.com/docs/maintenance.html#scheduled-gc&quot;&gt;Proxmox scheduled GC&lt;/a&gt; · &lt;a href=&quot;https://pbs.proxmox.com/docs/calendarevents.html&quot;&gt;Proxmox calendar events&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;proxmox-backup-manager datastore update store1 --gc-schedule &apos;sat 03:00&apos;
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Schedule verification and recheck on demand&lt;/h2&gt;
&lt;p&gt;Proxmox recommends reverifying all backups at least monthly. In this example, a job runs every Sunday at 03:00 in the server’s time zone. Setting &lt;code&gt;--ignore-verified false&lt;/code&gt; includes snapshots that have already passed verification. &lt;a href=&quot;https://pbs.proxmox.com/docs/maintenance.html#verification&quot;&gt;Proxmox verification&lt;/a&gt; · &lt;a href=&quot;https://pbs.proxmox.com/docs/command-syntax.html&quot;&gt;Proxmox command syntax&lt;/a&gt; · &lt;a href=&quot;https://pbs.proxmox.com/docs/calendarevents.html&quot;&gt;Proxmox calendar events&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;proxmox-backup-manager verify-job create weekly-verify --store store1 \
  --schedule &apos;sun 03:00&apos; --ignore-verified false
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To check the whole datastore now, run the command below. To check a single snapshot in the web interface, open the datastore’s &lt;strong&gt;Content&lt;/strong&gt; tab and select the verification icon in the snapshot’s &lt;strong&gt;Actions&lt;/strong&gt; column. &lt;a href=&quot;https://pbs.proxmox.com/docs/maintenance.html#verification&quot;&gt;Proxmox verification&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;proxmox-backup-manager verify store1 --ignore-verified false
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For a recovery test, follow the procedure in the Proxmox client guide. &lt;a href=&quot;https://pbs.proxmox.com/docs/backup-client.html#restoring-data&quot;&gt;Proxmox restore documentation&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The Proxmox Backup Server 4.2.14-1 documentation was checked on November 26, 2026. These steps were not run on a server.&lt;/em&gt;&lt;/p&gt;
</content:encoded><category>proxmox</category><category>backup</category><category>retention</category><category>verification</category><author>Homelab Backup Editorial</author></item><item><title>Safe Docker PostgreSQL Backups With pg_dump and NAS</title><link>https://homelabbackup.com/posts/safe-docker-postgresql-backups-pg-dump-nas/</link><guid isPermaLink="true">https://homelabbackup.com/posts/safe-docker-postgresql-backups-pg-dump-nas/</guid><description>Back up Docker PostgreSQL safely to a NAS using pg_dump and pg_dumpall, secure credentials with .pgpass, and verify restores with pg_restore.</description><pubDate>Thu, 26 Nov 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;To back up a running Docker PostgreSQL container to a NAS safely, export logical dumps with &lt;code&gt;pg_dump&lt;/code&gt; and &lt;code&gt;pg_dumpall --globals-only&lt;/code&gt; into a dedicated backup folder on your NAS. Direct file copies of an active PostgreSQL data directory are unsafe while the database server runs. &lt;code&gt;pg_dump&lt;/code&gt; produces internally consistent backups and generally allows other database operations to continue. Operations that require an exclusive lock, such as most forms of &lt;code&gt;ALTER TABLE&lt;/code&gt;, can be blocked.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Evidence and limits.&lt;/strong&gt; Checked on 2026-11-26 against the PostgreSQL 19 documentation, Docker CLI reference, and official Docker &lt;code&gt;postgres&lt;/code&gt; image documentation. This guide is not based on hands-on testing.&lt;/p&gt;
&lt;h2&gt;Why copying a live PostgreSQL data directory fails&lt;/h2&gt;
&lt;p&gt;Copying the PostgreSQL data directory directly while the database server is running risks an unusable backup. The &lt;a href=&quot;https://www.postgresql.org/docs/current/backup-file.html&quot;&gt;PostgreSQL File System Level Backup documentation&lt;/a&gt; requires shutting down the database server for a direct copy made with a tool such as &lt;code&gt;tar&lt;/code&gt; and before restoring it.&lt;/p&gt;
&lt;p&gt;Disallowing all connections does not make a plain file copy safe. Tools like &lt;code&gt;tar&lt;/code&gt; do not take an atomic file-system snapshot, and PostgreSQL also buffers data internally.&lt;/p&gt;
&lt;p&gt;A consistent frozen snapshot can be taken while the server runs if the file system supports it. Include the WAL files in the backup and take snapshots of all involved volumes simultaneously. A continuous-archiving base backup can also run while the server is up.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Backup method&lt;/th&gt;
&lt;th&gt;Database server state&lt;/th&gt;
&lt;th&gt;Scope&lt;/th&gt;
&lt;th&gt;Version portability&lt;/th&gt;
&lt;th&gt;Restore tool&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Logical dump (&lt;code&gt;pg_dump&lt;/code&gt; + &lt;code&gt;pg_dumpall -g&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;Running (&lt;code&gt;pg_dump&lt;/code&gt; can block operations that require an exclusive lock)&lt;/td&gt;
&lt;td&gt;Individual databases plus cluster-wide globals&lt;/td&gt;
&lt;td&gt;&lt;code&gt;pg_dump&lt;/code&gt; output generally loads into PostgreSQL versions newer than the &lt;code&gt;pg_dump&lt;/code&gt; version&lt;/td&gt;
&lt;td&gt;&lt;code&gt;pg_restore&lt;/code&gt; and &lt;code&gt;psql&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Direct file-system copy&lt;/td&gt;
&lt;td&gt;Completely shut down for full copy and restore&lt;/td&gt;
&lt;td&gt;Entire database cluster&lt;/td&gt;
&lt;td&gt;Server-version-specific&lt;/td&gt;
&lt;td&gt;Full-cluster file restore&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Continuous archiving and WAL (PITR)&lt;/td&gt;
&lt;td&gt;Running (continuous archiving + WAL)&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;Server-version-specific&lt;/td&gt;
&lt;td&gt;Continuous archive recovery&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Point-in-Time Recovery (PITR) with WAL archiving and NAS-specific backup application configuration are outside this setup guide. See the &lt;a href=&quot;/posts/&quot;&gt;homelab backup guides index&lt;/a&gt;. Browse &lt;a href=&quot;/topics/&quot;&gt;backup guides by topic&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Choosing pg_dump custom format and pg_dumpall globals&lt;/h2&gt;
&lt;p&gt;PostgreSQL provides two complementary logical dump utilities.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;https://www.postgresql.org/docs/current/app-pgdump.html&quot;&gt;&lt;code&gt;pg_dump&lt;/code&gt;&lt;/a&gt;&lt;/strong&gt; backs up a single database into a plain SQL script or an archive file. Passing custom format (&lt;code&gt;-Fc&lt;/code&gt; or &lt;code&gt;--format=custom&lt;/code&gt;) creates an archive for &lt;code&gt;pg_restore&lt;/code&gt; that supports selective restoration, item reordering, and parallel restoration. By default, &lt;code&gt;gzip&lt;/code&gt; compresses individual table-data segments at a moderate level.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;https://www.postgresql.org/docs/current/app-pg-dumpall.html&quot;&gt;&lt;code&gt;pg_dumpall&lt;/code&gt;&lt;/a&gt;&lt;/strong&gt; extracts an entire cluster, including the database roles, tablespaces, and configuration-parameter privilege grants that &lt;code&gt;pg_dump&lt;/code&gt; omits. Passing &lt;code&gt;-g&lt;/code&gt; or &lt;code&gt;--globals-only&lt;/code&gt; exports only global objects, such as roles and tablespaces, and skips all databases.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Combining &lt;code&gt;pg_dump -Fc&lt;/code&gt; for each database with &lt;code&gt;pg_dumpall --globals-only&lt;/code&gt; keeps archive flexibility while preserving cluster-wide roles. With a full &lt;code&gt;pg_dumpall&lt;/code&gt;, each database dump is internally consistent. The &lt;a href=&quot;https://www.postgresql.org/docs/current/backup-dump.html&quot;&gt;PostgreSQL SQL Dump documentation&lt;/a&gt; specifies that snapshots across different databases are not synchronized.&lt;/p&gt;
&lt;p&gt;Before running the dump commands, confirm the database name and the PostgreSQL role you will connect as. In the &lt;a href=&quot;https://github.com/docker-library/docs/blob/master/postgres/content.md&quot;&gt;official Docker &lt;code&gt;postgres&lt;/code&gt; image documentation&lt;/a&gt;, &lt;code&gt;POSTGRES_USER&lt;/code&gt; sets the initial superuser role (default &lt;code&gt;postgres&lt;/code&gt;), &lt;code&gt;POSTGRES_DB&lt;/code&gt; sets the initial database (defaulting to &lt;code&gt;POSTGRES_USER&lt;/code&gt;), and &lt;code&gt;PGDATA&lt;/code&gt; sets the cluster data path. The image uses &lt;code&gt;POSTGRES_USER&lt;/code&gt; and &lt;code&gt;POSTGRES_DB&lt;/code&gt; to initialize a database only when the container starts with an empty data directory.&lt;/p&gt;
&lt;h2&gt;Exporting dumps from Docker and Docker Compose&lt;/h2&gt;
&lt;p&gt;Keep pseudo-TTY allocation disabled for the redirected dump commands below.&lt;/p&gt;
&lt;p&gt;Use fresh output paths for both files on every run. Create a new subdirectory under your backup folder and use its path in the export commands below. Check that both &lt;code&gt;pg_dump&lt;/code&gt; and &lt;code&gt;pg_dumpall&lt;/code&gt; succeeded before treating the new files as a backup.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;pg_dump&lt;/code&gt; examples assume &lt;code&gt;&amp;lt;db_user&amp;gt;&lt;/code&gt; has read access to every table in the database. A complete &lt;code&gt;pg_dumpall&lt;/code&gt; dump usually requires a database superuser, and the globals examples assume that privilege. The globals script includes role password data by default, so restrict access to &lt;code&gt;globals.sql&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;https://docs.docker.com/reference/cli/docker/container/exec/&quot;&gt;&lt;code&gt;docker exec&lt;/code&gt;&lt;/a&gt;&lt;/strong&gt; (documented under &lt;code&gt;docker container exec&lt;/code&gt; in Docker Docs) does not allocate a pseudo-TTY by default. Omit &lt;code&gt;-t&lt;/code&gt; (&lt;code&gt;--tty&lt;/code&gt;) when redirecting dump output to a file. Use &lt;code&gt;-i&lt;/code&gt; (&lt;code&gt;--interactive&lt;/code&gt;) to keep standard input open when sending input to the container.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;https://docs.docker.com/reference/cli/docker/compose/exec/&quot;&gt;&lt;code&gt;docker compose exec&lt;/code&gt;&lt;/a&gt;&lt;/strong&gt; (Docker Docs) allocates a pseudo-TTY by default. Pass &lt;code&gt;-T&lt;/code&gt; (&lt;code&gt;--no-tty&lt;/code&gt;) to disable pseudo-TTY allocation. Compose keeps standard input open by default. For output-only automation, also pass &lt;code&gt;--interactive=false&lt;/code&gt; to disable interactive input.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Standalone Docker dump commands&lt;/h3&gt;
&lt;p&gt;Run these commands from the host to write a custom-format archive and a globals script to a local or NAS-mounted backup folder. Replace &lt;code&gt;&amp;lt;container&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;db_user&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;db_name&amp;gt;&lt;/code&gt;, and &lt;code&gt;/path/to/pg-backups&lt;/code&gt; with your values.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;docker exec &amp;lt;container&amp;gt; pg_dump -Fc -U &amp;lt;db_user&amp;gt; -d &amp;lt;db_name&amp;gt; &amp;gt; /path/to/pg-backups/&amp;lt;db_name&amp;gt;.dump
docker exec &amp;lt;container&amp;gt; pg_dumpall --globals-only -U &amp;lt;db_user&amp;gt; &amp;gt; /path/to/pg-backups/globals.sql
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If the NAS backup directory is already mounted at &lt;code&gt;/backups&lt;/code&gt; in the container, use &lt;code&gt;-f&lt;/code&gt; (&lt;code&gt;--file&lt;/code&gt;) to write the dumps directly there.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;docker exec &amp;lt;container&amp;gt; pg_dump -Fc -U &amp;lt;db_user&amp;gt; -d &amp;lt;db_name&amp;gt; -f /backups/&amp;lt;db_name&amp;gt;.dump
docker exec &amp;lt;container&amp;gt; pg_dumpall --globals-only -U &amp;lt;db_user&amp;gt; -f /backups/globals.sql
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Docker Compose dump commands&lt;/h3&gt;
&lt;p&gt;Use &lt;code&gt;-T&lt;/code&gt; and &lt;code&gt;--interactive=false&lt;/code&gt; for these output-only dumps, and replace &lt;code&gt;&amp;lt;service&amp;gt;&lt;/code&gt; with your PostgreSQL service name.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;docker compose exec -T --interactive=false &amp;lt;service&amp;gt; pg_dump -Fc -U &amp;lt;db_user&amp;gt; -d &amp;lt;db_name&amp;gt; &amp;gt; /path/to/pg-backups/&amp;lt;db_name&amp;gt;.dump
docker compose exec -T --interactive=false &amp;lt;service&amp;gt; pg_dumpall --globals-only -U &amp;lt;db_user&amp;gt; &amp;gt; /path/to/pg-backups/globals.sql
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can override the default &lt;code&gt;gzip&lt;/code&gt; compression on custom-format archives with &lt;code&gt;-Z&lt;/code&gt; or &lt;code&gt;--compress&lt;/code&gt; (PostgreSQL supports &lt;code&gt;gzip&lt;/code&gt;, &lt;code&gt;lz4&lt;/code&gt;, &lt;code&gt;zstd&lt;/code&gt;, or &lt;code&gt;none&lt;/code&gt;). The &lt;code&gt;pg_dump&lt;/code&gt; option &lt;code&gt;--no-owner&lt;/code&gt; (&lt;code&gt;-O&lt;/code&gt;) applies only to plain-text output. To skip restoring ownership from a custom archive, pass &lt;code&gt;--no-owner&lt;/code&gt; to &lt;code&gt;pg_restore&lt;/code&gt;.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command / Flag&lt;/th&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Documented purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-T&lt;/code&gt;, &lt;code&gt;--no-tty&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;docker compose exec&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Disables pseudo-TTY allocation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-i&lt;/code&gt;, &lt;code&gt;--interactive&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;docker exec&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Keeps &lt;code&gt;STDIN&lt;/code&gt; open even if unattached&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-u&lt;/code&gt;, &lt;code&gt;--user&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;docker compose exec&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Runs the command as the specified user&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-Fc&lt;/code&gt;, &lt;code&gt;--format=custom&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;pg_dump&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Creates a &lt;code&gt;pg_restore&lt;/code&gt; archive with default compression and support for selective and parallel restores&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-U&lt;/code&gt;, &lt;code&gt;--username&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;pg_dump&lt;/code&gt;, &lt;code&gt;pg_dumpall&lt;/code&gt;, &lt;code&gt;pg_restore&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Specifies the PostgreSQL role used to connect&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-d&lt;/code&gt;, &lt;code&gt;--dbname&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;pg_dump&lt;/code&gt;, &lt;code&gt;pg_restore&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Selects the database name to connect to&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-f&lt;/code&gt;, &lt;code&gt;--file&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;pg_dump&lt;/code&gt;, &lt;code&gt;pg_dumpall&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Writes these dumps to the specified file instead of standard output&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-Z&lt;/code&gt;, &lt;code&gt;--compress&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;pg_dump&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Sets the compression method (&lt;code&gt;gzip&lt;/code&gt;, &lt;code&gt;lz4&lt;/code&gt;, &lt;code&gt;zstd&lt;/code&gt;, or &lt;code&gt;none&lt;/code&gt;), level, or both&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-g&lt;/code&gt;, &lt;code&gt;--globals-only&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;pg_dumpall&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Dumps global objects such as roles and tablespaces and skips all databases&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3&gt;Credential handling for automated dumps&lt;/h3&gt;
&lt;p&gt;Avoid passing database passwords through &lt;code&gt;PGPASSWORD&lt;/code&gt; in automated scripts. The &lt;a href=&quot;https://www.postgresql.org/docs/current/libpq-envars.html&quot;&gt;PostgreSQL Environment Variables documentation&lt;/a&gt; warns that &lt;code&gt;PGPASSWORD&lt;/code&gt; is not recommended for security reasons because some operating systems let non-root users inspect process environment variables with &lt;code&gt;ps&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Also avoid setting &lt;code&gt;POSTGRES_HOST_AUTH_METHOD=trust&lt;/code&gt; to bypass passwords. The official Docker &lt;code&gt;postgres&lt;/code&gt; documentation advises against &lt;code&gt;trust&lt;/code&gt; because it permits host connections without a password.&lt;/p&gt;
&lt;p&gt;When the connection requires a password and none was specified, put a &lt;a href=&quot;https://www.postgresql.org/docs/current/libpq-pgpass.html&quot;&gt;PostgreSQL password file&lt;/a&gt; (&lt;code&gt;.pgpass&lt;/code&gt;) in the home directory of the user running the client inside the container. Use the field order &lt;code&gt;hostname:port:database:username:password&lt;/code&gt;. The first four fields accept &lt;code&gt;*&lt;/code&gt; as a wildcard. Escape a literal &lt;code&gt;:&lt;/code&gt; or &lt;code&gt;\&lt;/code&gt; within a field with a backslash. On Unix systems, libpq ignores &lt;code&gt;.pgpass&lt;/code&gt; if the file allows any group or world access. Restrict its permissions before use.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;chmod 0600 ~/.pgpass
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Verifying and restoring PostgreSQL dumps&lt;/h2&gt;
&lt;p&gt;Inspect the archive from your NAS, then restore the dumps into PostgreSQL to check that the restore works.&lt;/p&gt;
&lt;h3&gt;Inspecting a custom archive before restoring&lt;/h3&gt;
&lt;p&gt;List the recovered archive’s table of contents with &lt;a href=&quot;https://www.postgresql.org/docs/current/app-pgrestore.html&quot;&gt;&lt;code&gt;pg_restore&lt;/code&gt;&lt;/a&gt; &lt;code&gt;--list&lt;/code&gt; (&lt;code&gt;-l&lt;/code&gt;). When no filename argument is passed, &lt;code&gt;pg_restore&lt;/code&gt; reads the archive from standard input.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;docker exec -i &amp;lt;container&amp;gt; pg_restore --list &amp;lt; /path/to/recovery/&amp;lt;db_name&amp;gt;.dump
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With Docker Compose, use &lt;code&gt;-T&lt;/code&gt; and leave interactive input enabled so &lt;code&gt;pg_restore&lt;/code&gt; can read the archive from standard input.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;docker compose exec -T &amp;lt;service&amp;gt; pg_restore --list &amp;lt; /path/to/recovery/&amp;lt;db_name&amp;gt;.dump
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Restoring globals and databases&lt;/h3&gt;
&lt;p&gt;Restore cluster-wide roles and tablespaces first as a database superuser, with any required tablespace directories already in place. For both restore commands, replace &lt;code&gt;&amp;lt;restore_container&amp;gt;&lt;/code&gt; with the name of a fresh, disposable destination container. Initialize it with a different bootstrap superuser name from the source. By default, &lt;code&gt;psql&lt;/code&gt; continues after SQL errors. Pass &lt;code&gt;--set ON_ERROR_STOP=on&lt;/code&gt; as shown in the &lt;a href=&quot;https://www.postgresql.org/docs/current/backup-dump.html&quot;&gt;PostgreSQL SQL Dump documentation&lt;/a&gt; to stop on the first SQL error.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;docker exec -i &amp;lt;restore_container&amp;gt; psql -X --set ON_ERROR_STOP=on -U &amp;lt;db_superuser&amp;gt; postgres &amp;lt; /path/to/recovery/globals.sql
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Destructive restore warning.&lt;/strong&gt; The &lt;code&gt;--clean&lt;/code&gt; (&lt;code&gt;-c&lt;/code&gt;) flag instructs &lt;code&gt;pg_restore&lt;/code&gt; to drop the objects it will restore. With &lt;code&gt;--create&lt;/code&gt; (&lt;code&gt;-C&lt;/code&gt;), it drops and recreates the database named in the archive.&lt;/p&gt;
&lt;p&gt;To recreate and populate the database named inside the custom archive, set &lt;code&gt;&amp;lt;maintenance_db&amp;gt;&lt;/code&gt; to an existing database other than the one in the archive.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;docker exec -i &amp;lt;restore_container&amp;gt; pg_restore --clean --if-exists --create --exit-on-error -U &amp;lt;db_superuser&amp;gt; -d &amp;lt;maintenance_db&amp;gt; &amp;lt; /path/to/recovery/&amp;lt;db_name&amp;gt;.dump
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;pg_restore&lt;/code&gt; options work as follows.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;-C&lt;/code&gt; (&lt;code&gt;--create&lt;/code&gt;)&lt;/strong&gt;, used here with &lt;code&gt;--clean&lt;/code&gt;, uses the database specified by &lt;code&gt;-d&lt;/code&gt; only for the initial &lt;code&gt;DROP DATABASE&lt;/code&gt; and &lt;code&gt;CREATE DATABASE&lt;/code&gt; commands. The restore goes into the database named in the archive.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;--if-exists&lt;/code&gt;&lt;/strong&gt; requires &lt;code&gt;--clean&lt;/code&gt; and uses &lt;code&gt;DROP ... IF EXISTS&lt;/code&gt; to suppress errors for objects that are missing from the destination.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;--exit-on-error&lt;/code&gt;&lt;/strong&gt; stops the restore if an error occurs while sending SQL commands to the database. By default, &lt;code&gt;pg_restore&lt;/code&gt; continues and prints an error count at the end.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;-1&lt;/code&gt; (&lt;code&gt;--single-transaction&lt;/code&gt;)&lt;/strong&gt; wraps the restore in one &lt;code&gt;BEGIN&lt;/code&gt; / &lt;code&gt;COMMIT&lt;/code&gt; block and implies &lt;code&gt;--exit-on-error&lt;/code&gt;. PostgreSQL documents that &lt;code&gt;--single-transaction&lt;/code&gt; cannot be combined with &lt;code&gt;--create&lt;/code&gt; or parallel &lt;code&gt;--jobs&lt;/code&gt; (&lt;code&gt;-j&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;-j&lt;/code&gt; (&lt;code&gt;--jobs&lt;/code&gt;)&lt;/strong&gt; enables parallel restoration on custom or directory archives when &lt;code&gt;pg_restore&lt;/code&gt; connects directly to the database. It requires a regular file or directory as input. For &lt;code&gt;-j&lt;/code&gt; with &lt;code&gt;docker exec&lt;/code&gt;, pass &lt;code&gt;pg_restore&lt;/code&gt; the archive path inside the container.&lt;/li&gt;
&lt;/ul&gt;
</content:encoded><category>docker</category><category>postgresql</category><category>pg-dump</category><category>pg-restore</category><category>nas</category><author>Homelab Backup Editorial</author></item></channel></rss>