Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

The safest practical backup plan for a small Ubuntu VPS combines a scheduled logical dump for each important database, a separate globals dump for roles and tablespaces, encryption, and a copy stored outside the VPS. If you must recover the entire cluster to a particular time, add a pg_basebackup and continuous WAL archiving. A pg_dump file can restore database objects and rows, but it cannot provide point-in-time recovery (PITR) because logical dumps do not participate in WAL replay.

Choose the backup method that matches the failure you need to survive

PostgreSQL has three distinct backup families. They are complementary rather than interchangeable: a logical dump is excellent for one database or a selective migration, while a base backup plus WAL archive is the method for rebuilding a complete cluster at a chosen moment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Need Recommended method What it restores Main trade-off
Recover one database or migrate data pg_dump A logical copy of one database Restore can take time and there is no PITR
Preserve roles and cluster-wide globals pg_dumpall --globals-only Roles, tablespace definitions, and related global objects Logical output; it does not replace a data dump
Recover the whole cluster to a recent or selected time pg_basebackup plus archived WAL The complete cluster and a point on its WAL timeline More storage, configuration, monitoring, and operational complexity

PostgreSQL’s Chapter 25 documentation states: “As with everything that contains valuable data, PostgreSQL databases should be backed up regularly.” The useful definition of “regularly” is the interval your business can tolerate losing. A daily dump may be adequate for a low-change personal application; a busy service with a five-minute data-loss objective needs continuous WAL archiving or another separately designed replication and backup system.

Prepare the Ubuntu VPS before taking a backup

Inventory the cluster and databases

Record the PostgreSQL major version, cluster name, listening address, database names, owners, tablespaces, and approximate database sizes. On Ubuntu, the client utilities are commonly installed with the PostgreSQL client package, but the command on your path must be the version you intend to use. Check the installed utility’s options with pg_dump --version, pg_restore --version, and pg_basebackup --version; verify the flags against that installed major version before automating them.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Choose an account and authentication method

The dump role must be able to read every object you intend to back up. A database owner or suitably privileged backup role is normally used. Test authentication non-interactively using the same operating-system account and connection parameters that the scheduled job will use. If you use a password file, protect it so only that account can read it; never place a database password directly in a world-readable script or command line.

Reserve a protected staging directory

Keep temporary dump files away from application directories and restrict the directory to the backup operator:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo install -d -m 0700 -o postgres -g postgres /var/backups/postgresql

Confirm that the filesystem has room for a new dump, its compressed or encrypted copy, and at least one older generation. A dump written successfully is still a failed backup if the disk fills before it can be copied away.

Create logical backups with pg_dump

Use a format suited to the restore you expect

For a database named appdb, a custom-format dump is a flexible default:

pg_dump -Fc -d appdb -f /var/backups/postgresql/appdb-$(date +%F).dump

The custom format is not human-readable, but it works with pg_restore, supports selective object restoration, and is suitable for parallel restore when the target and workload justify it. The directory format is another useful choice when you want a set of files and parallel dump or restore operations. Plain SQL is readable and portable: it can be loaded with psql, but selective restoration and parallelism are less convenient.

Adapt the database name, connection options, owner, and path. The example is a command pattern, not a guarantee for every Ubuntu or PostgreSQL release. Confirm available disk space, authentication, permissions, and client/server compatibility before production use.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Export cluster-wide globals separately

pg_dump covers one database. Roles, tablespace definitions, and other cluster-wide objects belong in a separate export:

pg_dumpall --globals-only > /var/backups/postgresql/globals-$(date +%F).sql

Restore this file before loading database data when the target cluster does not already contain the required roles or tablespaces. Keep the globals file with the matching data dumps so ownership and grants can be recreated consistently.

When a full pg_dumpall is appropriate

pg_dumpall without --globals-only writes every database in the cluster to one SQL script. It can be convenient for a very small cluster, but the single large script is less flexible for selective restores and can be slower to handle during an incident. Separate pg_dump files normally make it easier to restore only the affected database and to run independent retention policies.

Compress, encrypt, and move dumps off the VPS

Compression and encryption are separate controls

Custom and directory formats already apply their own dump-format handling, but you still need to consider transfer size and confidentiality. Compress a plain SQL export before transfer, and encrypt every backup that could expose customer, employee, credential, or proprietary data. For example, an operator might create an encrypted copy with a locally managed key:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
gzip -c /var/backups/postgresql/globals-2026-10-14.sql > /var/backups/postgresql/globals-2026-10-14.sql.gz
gpg --batch --yes --output /var/backups/postgresql/appdb-2026-10-14.dump.gpg --encrypt --recipient backup@example.invalid /var/backups/postgresql/appdb-2026-10-14.dump

Use your organization’s key-management process rather than copying a private key onto the same VPS. Verify that the recipient key is current and that a recovery operator can access it during a disaster. Encryption does not replace access control: restrict the archive directory and the remote destination as well.

Keep a copy outside the failure domain

Copy completed, verified files to storage that will survive loss, compromise, or an unavailable VPS. Retain more than one generation and keep at least one copy outside the VPS. A removable external drive can be secondary storage for downloaded dumps or base-backup archives, but by itself it supplies no continuous WAL archiving, encryption, monitoring, or geographic redundancy. Rotate it away from the server and protect it from unauthorized access if you use one.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Automate recurring logical backups

A scheduled job should create the dump, export globals, apply protection, transfer the result, record success or failure, and remove only files older than your documented retention period. Run it under a dedicated account with the minimum filesystem and database privileges. Do not silently ignore errors: a script that continues after pg_dump fails can upload an empty or partial artifact.

A simple cron entry can invoke a version-controlled script rather than embedding a long command in the crontab:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
15 2 * * * /usr/local/sbin/postgresql-backup >> /var/log/postgresql-backup.log 2>&1

The script should use a temporary filename, check each command’s exit status, set restrictive umask permissions, and rename the file only after the dump and any encryption step completes. Add monitoring for missed runs, transfer failures, and unexpectedly small files. Treat the retention period as a recovery decision: if you retain seven daily dumps, a corruption discovered on day eight may be unrecoverable unless another backup family covers it.

Use base backups and WAL archiving for point-in-time recovery

Understand what WAL adds

PostgreSQL continuously writes write-ahead log (WAL) records under pg_wal. A base backup captures the cluster’s files at a known starting point; the archived WAL files record changes after that point. With an intact base backup and every required WAL segment, you can restore the cluster to a selected time after the base backup, subject to the available archive history. PostgreSQL’s normal WAL segment size is 16 MB, although the segment size can be changed when the cluster is initialized.

Logical dumps cannot be replayed through WAL. They therefore cannot provide PITR, even if you copy them every few minutes. PITR also requires the complete cluster context, including system catalogs and configuration decisions represented in the data directory.

Configure archiving

Set the required server parameters in the active PostgreSQL configuration:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
wal_level = replica
archive_mode = on
archive_command = 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f'

The documented command is an example, not a universal production recommendation. The archive destination must survive loss of the VPS, and the copy operation should be replaced or supplemented with a secure, monitored transfer appropriate to your environment. The command runs as the PostgreSQL server user. It must return success only after the WAL file is safely archived, and it must not overwrite a different file under the same WAL name. Protect the archive because it contains the database’s changes.

After changing settings that require a restart, restart the correct Ubuntu cluster during a controlled maintenance window. Validate that archiving is actually succeeding rather than assuming that a syntactically valid setting is operational. Monitor archive success and lag continuously.

Take a base backup with pg_basebackup

pg_basebackup is PostgreSQL’s easiest documented method for making a physical base backup. Store the resulting backup outside the live data directory and copy it to the same independent storage used for the WAL archive. Record the base-backup start time and retain every WAL segment needed from that time forward. A base backup without its required WAL history is not a complete PITR set.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use replication authentication and a replication-capable connection as required by your PostgreSQL configuration. Choose a destination with enough capacity for a full cluster plus future WAL and verify the result before deleting any older base backup. The exact connection, checkpoint, compression, and slot options vary by installed major version, so consult the local utility help and documentation before placing a command in production.

Restore a logical dump

Restore a custom-format dump

  1. Provision a clean target PostgreSQL cluster or database and confirm that its major version and extensions meet the application’s requirements.
  2. Restore the globals file first when roles or tablespaces are needed: psql -f globals-2026-10-14.sql postgres.
  3. Create the target database with the intended owner and encoding, or let pg_restore create it when the dump and permissions allow that workflow.
  4. Load the custom dump with pg_restore, supplying the target connection and any deliberate ownership or privilege options. Use a transaction or a controlled maintenance window where appropriate.
  5. Inspect row counts, key application queries, extensions, sequences, permissions, and background jobs before directing users to the restored database.

For a directory or custom dump, pg_restore can restore selected schemas or objects and may support parallel jobs. Parallelism reduces elapsed time only when the target storage and CPU can handle concurrent work; it does not make a damaged or incomplete dump recoverable.

Restore a plain SQL file

Plain SQL output is loaded with psql:

psql -X -d appdb -f appdb-2026-10-14.sql

Use -X to avoid unexpected settings from a user startup file during an automated restore. Restore globals separately, ensure the target role exists, and review any statements that create databases, alter ownership, or install extensions before running the file in a production environment.

Best Value
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Perform a point-in-time recovery

PITR replaces the target cluster’s data directory with a base backup and then replays archived WAL. Plan a controlled outage or an isolated recovery host; never experiment first on the only copy of the original cluster.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Stop PostgreSQL on the recovery target and preserve the existing data directory if possible. It may contain evidence or files needed for another recovery attempt.
  2. Restore the base backup with ownership and permissions matching the PostgreSQL operating-system user.
  3. Copy any WAL that was still local and had not yet reached the archive destination, if it is available and required.
  4. Configure restore_command so PostgreSQL can fetch each archived WAL file. The command must fail clearly when a required file is unavailable rather than returning false success.
  5. Create the recovery.signal file in the restored data directory.
  6. Set the desired recovery target, such as a date/time or a named restore point, using the recovery settings supported by the installed major version.
  7. Start PostgreSQL and watch the server log until recovery completes or reports a missing, corrupt, or incompatible WAL segment.
  8. Inspect the recovered database on an isolated connection: validate critical tables, recent transactions, sequences, extensions, users, and application invariants.
  9. Only after inspection, promote or reopen the recovered cluster and redirect application traffic.

WAL recovery does not restore manually edited postgresql.conf, pg_hba.conf, or pg_ident.conf. Back up those files, service definitions, firewall rules, TLS material, application configuration, and other VPS settings separately. A database-only recovery cannot recreate an entire server.

Monitor the backup system and respond to failures

Archive command failures

If an archive command repeatedly fails, PostgreSQL retains WAL in pg_wal while it waits for successful archiving. The directory can grow until the filesystem fills; PostgreSQL may then perform a PANIC shutdown and remain offline until space is freed. Alert on archive failures and lag before this becomes an outage. Do not “fix” the symptom by deleting WAL files manually.

Incomplete or misleading backup files

  • Check exit codes for every dump, compression, encryption, and transfer command.
  • Write to a temporary name and publish only after the final file is complete.
  • Record the database name, cluster, PostgreSQL version, start and end time, and checksum with each artifact.
  • Reject zero-byte or unexpectedly small files and investigate sudden size changes.
  • Verify that the remote copy exists and is readable by a recovery account.

Archive security and collisions

Restrict archive directories from group and world reads. An archive command must not overwrite a pre-existing file with different contents under the same WAL filename; the documented test ! -f pattern demonstrates that safety property. Apply retention only after confirming that at least one valid base backup still has all WAL required for its recovery window.

Test restores instead of trusting successful jobs

A green scheduler status proves only that a process exited successfully. A backup is operationally complete when a restore has been rehearsed and the resulting database inspected. At a documented interval, restore the newest logical dump to an isolated PostgreSQL instance and perform representative application checks. Separately, restore a base backup with archived WAL and recover to a known timestamp or named restore point.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Measure the elapsed time from starting recovery to accepting validated application traffic. Compare that recovery time objective and recovery point objective with the business requirement. Record missing extensions, role mismatches, ownership errors, incompatible client versions, absent configuration files, and any manual steps; turn each discovery into an updated script or runbook.

A practical backup policy for a small Ubuntu VPS

  • Run a per-database pg_dump on a schedule that meets the acceptable data-loss window.
  • Run pg_dumpall --globals-only alongside those dumps.
  • Encrypt completed files and transfer them to storage outside the VPS.
  • Keep multiple generations and document retention and deletion rules.
  • Add pg_basebackup and continuous WAL archiving when whole-cluster recovery or PITR is required.
  • Monitor dump completion, archive lag, destination capacity, and transfer success.
  • Back up Ubuntu and PostgreSQL configuration separately.
  • Rehearse both logical and PITR restores and inspect the recovered data before declaring the plan effective.

This combination gives a small deployment a straightforward path for restoring one database while preserving an upgrade path to full-cluster, time-targeted recovery. The important distinction is not the number of copies alone: it is whether the copies, WAL history, credentials, configuration, and restore procedure remain available when the VPS does not.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.