Ask Steves · Daily notes · VPS, 20% off · AI Profit Lab · SEO · Money Hub

5 November 2026 · Practical AI builds

How do I back up a small AI app and its data on a VPS?

By the end of this you will have a nightly, encrypted copy of your AI app, its database and its uploaded files, stored away from the server it runs on. You will also have checked that you can get it back. It suits anyone running one small app on one VPS, such as a chatbot, an FAQ bot or a document tool, who would lose real work if that server broke.

I learn my automation tips in the AI Profit Boardroom. Have a look here. Affiliate link.

What you need

Step by step

  1. Make a list of what the app cannot live without: the code folder, the .env or config file, uploaded files, any vector store or index the AI reads from, the database, and the nginx and PM2 or Docker Compose files that start it.
  2. Install restic with sudo apt install restic and create a bucket or folder at your storage provider, with a key that can only reach that one bucket.
  3. Create a password for the backup, save it in your password manager, then put it in a file only root can read, such as /root/.restic-pass with permissions 600. Without this password the backup cannot be opened by anyone, including you.
  4. Set up the backup store once with restic init, pointing it at your bucket. Restic will refuse to start if the password file or storage keys are wrong, which is a useful early check.
  5. Dump the database to a plain file first, rather than copying the live database files while the app is writing to them. If you have not done this before, see how to back up a Postgres database from the command line.
  6. Write a short script that does the dump, then the backup, then tidies up old copies. A simple version looks like this:
    #!/bin/sh
    set -e
    export RESTIC_REPOSITORY=s3:https://s3.example.com/appname-backups
    export RESTIC_PASSWORD_FILE=/root/.restic-pass
    export AWS_ACCESS_KEY_ID=yourkeyid
    export AWS_SECRET_ACCESS_KEY=yoursecret
    
    pg_dump -U appuser appname > /var/backups/appname/db.sql
    restic backup /var/backups/appname /srv/appname /etc/nginx
    restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prune
  7. Make the script readable only by root (chmod 700), since it holds storage keys, and run it once by hand to make sure it finishes without errors.
  8. Schedule it every night with cron, sending the output to a log so you can see what happened:
    0 3 * * * /usr/local/bin/backup-appname.sh >> /var/log/backup-appname.log 2>&1
  9. Test a restore into a spare folder with restic restore latest --target /tmp/restore-test, open a few files, and load the database dump into a test database to check it is complete.
  10. Put a reminder in your calendar to repeat that restore test every month or two.

What good looks like

Running restic snapshots shows one new snapshot every night, the log ends without errors, and the storage bucket grows slowly rather than by the full size of your app each time. Most importantly, you have restored a copy into a test folder, started the app from it or loaded its database, and seen your own data come back as it should.

Watch out for

The most common mistake is a backup that has never been restored. It might be missing the database, the config file or the folder where uploads really live, and you only find out on the bad day. If your app runs in Docker, its data may sit in a Docker volume rather than a folder you expected, so dump the database from inside the container (for example with docker exec) and check which volumes hold files. Also remember that backups hold everything your app holds: customer messages, uploaded documents and API keys. Keep them encrypted, keep the storage keys limited to that one bucket, and delete old copies on a schedule so you are not keeping personal data longer than you need to.

Questions people ask

Are my hosting provider's snapshots enough on their own?

They are a useful extra, but they usually live with the same provider and sometimes in the same data centre, so a billing problem or account lockout can take them too. A second copy somewhere else, under your own control, covers that.

Do I need to back up the AI model itself?

Usually not. If you call a model through an API, there is nothing to copy, and if you run an open model locally you can download it again. Back up your prompts, settings, documents and any index you built from them, because those are yours and harder to rebuild.

In short: dump the database, let restic copy the dump and the app's folders to encrypted storage somewhere else every night, keep a sensible number of old copies, and prove it works by restoring it now and then.

You can get the same kind of VPS with 20% off at https://asksteves.co.uk/vps. Affiliate link.

Want more automation tips? The AI Profit Boardroom on Skool is where I get mine. Have a look here. Affiliate link.

Everything on this blog runs on one Hostinger KVM 8. This link takes 20% off the same box.

GET A VPS, 20% OFF →

Affiliate link.

Related AI builds: How do I keep private data out of AI tools? · How do I build a chatbot that answers from my own files? · How do I choose between a hosted AI model and one I run myself? · All daily notes