Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
VGSources
Blog

How to Back Up a Self-Hosted AI Agent on a VPS

A VPS snapshot alone can miss volumes and application state. This guide shows how to preserve your deployment, export Docker data, dump databases, encrypt off-site copies, and verify a clean-server restore.
Length12 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The reliable way to back up a self-hosted AI agent is to use several layers, not one VPS snapshot: preserve the rebuild definition, export volumes and bind mounts, create database-aware dumps, encrypt copies off the server, and test a full restore on a clean VPS. A provider image is useful for fast rollback, but it may omit attached volumes and cannot replace portable application backups.

The backup design that survives a VPS failure

Your agent is more than a running container. A complete recovery set must recreate the operating environment, application state, and data services that make the agent useful. Separate the backup into these layers:

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Layer What it contains Purpose
Rebuild Docker Compose files or systemd units, image tags or immutable digests, environment-variable names, reverse-proxy and TLS configuration, firewall rules, scripts, prompts, tool definitions, and deployment notes Reconstruct the host and start the same software
Application data Named Docker volumes, bind-mounted directories, agent memory, uploaded files, vector indexes, SQLite files, model and embedding caches that cannot be downloaded again Restore the agent’s working state
Database Logical dumps from PostgreSQL or another database, plus cluster-wide roles and tablespaces where applicable Recover records consistently and independently of a filesystem image
Provider recovery VPS backups or snapshots Fast rollback, cloning, or emergency recovery of the server disk
Off-site repository Encrypted archives copied to separate object storage or another host Survive provider failure, account lockout, ransomware, or accidental deletion on the VPS

Keep the off-site repository credentials and encryption password outside the VPS. If an attacker controls the agent host, credentials stored only there can let the attacker erase every copy.

Inventory everything before copying it

Start with an inventory that another administrator could use without guessing. Run the following from the deployment directory and save the results in your operations documentation:

#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.
  1. docker compose config > compose.rendered.yml to capture the fully resolved Compose configuration.
  2. docker volume ls to list named volumes.
  3. docker inspect <container> and review the Mounts entries for bind-mounted host paths and volumes.
  4. List database names, users, ports, extensions, and where each database stores its data.
  5. Record image tags and, for reproducibility, immutable image digests. A floating tag can point to different software after a rebuild.
  6. List model, embedding, tokenizer, and vector-index caches. Mark which files can be re-downloaded and which are licensed, customized, or too large to recreate quickly.
  7. List scheduled jobs, webhook endpoints, TLS certificate locations, firewall rules, monitoring checks, and any systemd units or cron files.

Do not put secret values in the inventory. Record variable names and the location of the encrypted secret store instead. Include a documented process for rotating or recreating API keys, OAuth clients, webhook signing secrets, and provider credentials.

Preserve the deployment definition and operational files

Docker Compose deployments

Back up the Compose YAML, override files, rendered configuration, image references, helper scripts, and the directory structure expected by bind mounts. Include health checks, networks, resource limits, device mappings, and restart policies. If the agent uses a local model runtime or GPU, document the host driver and runtime requirements rather than assuming a new VPS has them.

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

Store a sanitized .env.example containing every required variable name and a separate encrypted copy of the real values. The sanitized file should make missing configuration obvious while never becoming a credential dump.

systemd or mixed deployments

Copy unit files, drop-in overrides, timer definitions, environment files, reverse-proxy configuration, TLS automation settings, firewall exports, and deployment scripts. Note package versions and the commands used to install them. A snapshot that restores a disk may boot, but a portable runbook is what lets you move to another provider or rebuild after corruption.

Agent-specific state

Prompts, tool schemas, routing rules, conversation policies, allowlists, memory settings, and evaluation fixtures are part of the application. Include them even when they are stored outside the main repository. For a game assistant, also preserve game-server connection settings, mod or plugin configuration, scheduled match jobs, and webhook mappings that the agent uses to perform actions.

Back up Docker volumes and bind mounts

Docker describes volumes as persistent data stores managed by Docker. They survive container removal, but a container’s writable layer is not a dependable backup target. Export every named volume and every host directory mounted into a container.

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

Export a named volume

Stop the service first when writes must be frozen. If the application supports a maintenance or read-only mode, use that when a full stop would disrupt other services. Then create a compressed archive with a temporary helper container:

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.
docker compose stop agent
mkdir -p backups/volumes
docker run --rm 
  -v agent_data:/data:ro 
  -v "$PWD/backups/volumes:/backup" 
  alpine tar czf /backup/agent_data-$(date +%F).tar.gz -C /data .

Replace agent_data with the actual volume name. The read-only mount prevents the helper from changing application files; stopping the writer is what provides a consistent point-in-time archive.

Export a bind-mounted directory

For a host path such as /srv/agent/uploads, archive the directory directly after quiescing writes:

tar czf backups/uploads-$(date +%F).tar.gz -C /srv/agent uploads

Back up ownership, permissions, symbolic links, and extended attributes when the application depends on them. GNU tar options such as --xattrs and --acls may be appropriate on your distribution; verify the restore on the same filesystem type you expect to use in production.

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

Restore a volume

Create the destination volume, unpack the archive into its root, then start the service:

docker volume create agent_data-restored
docker run --rm 
  -v agent_data-restored:/data 
  -v "$PWD/backups/volumes:/backup:ro" 
  alpine sh -c 'tar xzf /backup/agent_data-2026-10-14.tar.gz -C /data'
# After checking ownership and contents:
docker compose up -d agent

Use the archive’s actual date and volume name. Check that the container user can read and write the restored files; a root-owned directory can look intact while causing silent application failures.

What belongs in application archives

  • Conversation or long-term memory stores.
  • Uploaded documents, screenshots, audio, and generated assets.
  • Vector indexes and metadata used for retrieval.
  • SQLite databases and lock-free copies produced by the database’s supported backup method.
  • Local model weights, adapters, embedding models, and tokenizer caches when re-downloads are impractical or impossible.
  • Queue state or job artifacts when losing them would duplicate actions or miss scheduled work.

For stateful services that continue writing during a tar operation, the archive may be crash-consistent rather than application-consistent. Stop or pause writers, or use the service’s own export mechanism, whenever the distinction matters.

Dump databases with database-aware tools

PostgreSQL

pg_dump produces a consistent logical dump while users continue reading and writing. A custom-format dump is compact and works with pg_restore; a directory-format dump supports parallel restore for larger databases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.
# Custom format, one database
pg_dump --format=custom --file=backups/agent-$(date +%F).dump "$DATABASE_URL"

# Directory format for parallel restore
pg_dump --format=directory --file=backups/agent-$(date +%F)-dir "$DATABASE_URL"

# Cluster-wide roles and tablespaces
pg_dumpall --globals-only > backups/postgres-globals-$(date +%F).sql

Run the dump with a role that can read every required schema, and verify that the output file is non-empty before uploading it. Keep the globals dump when the restore depends on roles, ownership, tablespaces, or passwords defined outside an individual database.

On a new server, create the target database and restore the globals before restoring objects that reference those roles:

psql -f backups/postgres-globals-2026-10-14.sql postgres
createdb agent_restored
pg_restore --clean --if-exists --no-owner 
  --dbname=agent_restored backups/agent-2026-10-14.dump

Adjust ownership flags to your security model. A restore drill should test extensions, permissions, sequences, large objects, and application migrations, not merely whether the command exits successfully.

SQLite and embedded databases

Do not copy a live SQLite file with a generic archive while transactions are in progress. Use the SQLite backup or dump mechanism supported by the deployed SQLite version, then include the resulting file in the application archive. Record the SQLite version and journal mode so that a clean host can reproduce the same behavior.

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

Choosing a PostgreSQL backup approach

PostgreSQL documentation groups backups into SQL dumps, filesystem-level backups, and continuous archiving. Logical dumps are portable and convenient for a self-hosted agent; filesystem or continuous-archiving approaches become more attractive as database size and recovery objectives grow. Choose based on acceptable data loss, restore time, and operational complexity rather than assuming one method fits every workload.

Encrypt and copy backups off the VPS

An archive sitting beside the agent protects against a broken container but not against a compromised server, disk loss, or provider account failure. Use an encrypted repository on S3-compatible object storage or another independent host. Restic is one practical option: its repository is encrypted, supports snapshots and retention policies, and can be checked for integrity.

Initialize and create a Restic repository

The exact endpoint and credential variable names depend on your object-storage service. Keep the repository password in a password manager or separate secret store, not in a file readable by the agent:

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
export AWS_ACCESS_KEY_ID='stored-outside-the-vps'
export AWS_SECRET_ACCESS_KEY='stored-outside-the-vps'
export RESTIC_PASSWORD='stored-outside-the-vps'
export RESTIC_REPOSITORY='s3:https://object-storage.example/agent-backups'

restic init
restic backup /srv/agent /etc/agent /var/lib/docker/volumes 
  --exclude='*/cache/*'
restic check

The example excludes a cache path only if that cache is genuinely reproducible. Do not exclude model files, memory, uploads, or indexes merely because they are large. Decide exclusions from the inventory and document every one.

Restic’s encryption protects repository contents, but losing the repository password can make every snapshot unrecoverable. Retain a recovery copy of the password and object-storage credentials away from the VPS, with access limited to the people who can perform a restore.

Schedule backups

Run the script from cron or a systemd timer under a dedicated account. A production job should:

  1. Put the agent and other writers into a safe state, or call database dump commands first.
  2. Create database dumps and volume archives in a staging directory.
  3. Run the encrypted repository backup.
  4. Run restic check on a defined cadence.
  5. Record success or failure in monitoring and remove staging files only after a successful upload.

Schedule database dumps before the file archive so the archive contains the newest logical export. Test the timer after enabling it; a unit that is enabled but never triggered is not a backup system.

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

Retention

A reasonable starting policy is several recent daily copies, a few weekly copies, and monthly copies for longer-lived configuration and data. This is a planning baseline, not a universal requirement. Tune retention to how quickly the agent changes, storage cost, and how much recovery-point loss you can accept. Keep at least one copy logically or physically separated from credentials used by the VPS.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Are VPS snapshots enough?

No. A snapshot or provider backup is a valuable provider-recovery layer, but it is not automatically a complete application backup. Scope, retention, and portability differ by provider and plan, and attached volumes may be excluded.

Method Attached-volume coverage Database consistency Portability Restore granularity Encryption and credential isolation Automation and retention Best use
Provider snapshot or VPS backup Provider-specific; Hetzner states attached Volumes are not included in Backups or Snapshots Disk-image consistency; not a database-aware dump Usually tied to the provider Whole server or image-level recovery Depends on provider account and storage controls Provider-defined; Hetzner offers seven automatic daily Backup slots Fast rollback, cloning, and emergency server recovery
Restic encrypted archive Any paths and exported volumes you include As consistent as the dumps and quiescing steps you perform Portable to another host and compatible object storage Individual files, directories, or selected snapshots Repository encryption; credentials can remain outside the VPS You control schedules, checks, and retention Independent disaster recovery and granular restores
Manual exports Only what you explicitly export Can be database-aware when using pg_dump or an equivalent tool Usually highly portable Database, volume, or file-level Requires you to encrypt and protect the copies Easy to forget unless automated Migration, validation, and an additional recovery copy

Hetzner Cloud

Hetzner documents automatic daily server Backups with seven slots. Manual Snapshots persist until deleted. Its documentation also states that attached Volumes are not included in server Backups or Snapshots, so a deployment using a separate Volume needs an independent volume export. Hetzner recommends maintaining an independent backup in addition to provider copies.

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.

DigitalOcean

DigitalOcean documents selectable Droplet backup intervals of four hours, six hours, twelve hours, daily, or weekly, and supports creating or restoring Droplets from those disk images. Confirm the current plan, region, retention, scope, and pricing before relying on a particular interval. Treat the image as a server-disk recovery layer and keep application exports elsewhere.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

Restore the agent on a clean VPS

A restore drill is the proof that your backups contain enough information. Perform it on a newly provisioned server rather than overwriting production.

  1. Provision and harden the host. Create a clean VPS, update the operating system, configure a non-root administrator, firewall rules, SSH access, and the runtime versions required by your pinned images.
  2. Retrieve credentials safely. Obtain the object-storage credentials and Restic password from the independent secret store. Do not commit them to the restored repository or paste them into a public issue.
  3. Recover the rebuild layer. Restore Compose files or systemd units, reverse-proxy and TLS configuration, scripts, prompts, tool definitions, and the sanitized environment template. Pin the recorded image tags or digests.
  4. Recreate secrets and integrations. Rotate or recreate API keys, OAuth clients, webhook secrets, game-server credentials, and monitoring tokens according to the documented procedure.
  5. Restore databases. Install the matching database version, restore PostgreSQL global objects when required, create databases, run pg_restore or the appropriate SQLite restore, and apply only migrations newer than the dump.
  6. Restore volumes and bind mounts. Create destination volumes, unpack archives with correct ownership and permissions, and restore uploaded files, memory, indexes, and non-reproducible model assets.
  7. Start services in dependency order. Bring up the database and storage services first, then the agent, workers, reverse proxy, and scheduled jobs. Watch logs for failed migrations, missing extensions, permission errors, and invalid environment variables.
  8. Verify user-visible behavior. Test login, agent responses, memory retrieval, file upload and download, model selection, tool calls, scheduled jobs, webhooks, TLS, monitoring alerts, and any game-server integration.
  9. Measure and update. Record elapsed restore time, which files or credentials were missing, and every manual workaround. Update the runbook and repeat until another operator can complete the process.

Common backup failures and fixes

The snapshot restored the OS but the agent lost its memory

Check whether memory lived on an attached Volume or bind mount excluded from the image. Export that path separately and include it in the restore checklist.

The container starts but behaves like a new installation

The writable container layer was probably treated as persistent storage, or the named volume was not attached to the restored service. Compare the restored Compose mounts with the inventory and restore the correct volume.

PostgreSQL restores fail on ownership or extensions

Restore cluster-wide roles first, install required extensions, and verify that the target database user exists. Use the dump format and pg_restore options that match your ownership policy instead of forcing every object to be owned by the administrator.

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

The archive exists but cannot be decrypted

Restic requires its repository password. Recover the password from the independent secret store, then test access from a second machine. A password that exists only in a VPS environment file is not a disaster-recovery plan.

Backups report success but contain stale data

Inspect job ordering and timestamps. Ensure database dumps run before the archive, writers are paused when needed, and the scheduler actually triggers. Add monitoring for failed commands and for unexpectedly small dump or snapshot sizes.

Restores work only on the original provider

Provider images are often vendor-specific. Keep Compose or systemd definitions, database dumps, volume archives, and infrastructure notes in portable formats, and perform at least one clean-host restore without using a provider snapshot.

A practical pre-disaster checklist

  • Deployment files, image tags or digests, scripts, firewall, proxy, TLS, prompts, and tool definitions are versioned.
  • Secret names and recreation or rotation steps are documented; secret values are stored independently.
  • Every Docker volume and bind mount has an owner, purpose, and tested export.
  • PostgreSQL databases have regular pg_dump files, with pg_dumpall --globals-only when cluster objects matter.
  • SQLite and other embedded stores are exported with their supported backup mechanism.
  • Archives are encrypted and copied outside the VPS.
  • Repository passwords and object-storage credentials have an off-server recovery copy.
  • Restic integrity checks and scheduler failures reach monitoring.
  • Provider snapshots or backups are enabled for fast rollback, with their actual scope recorded.
  • A clean-VPS restore has been completed and the runbook reflects what happened.

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.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.