Skip to content

Backup & Restore

Back up and restore V2RayTun panel data — database, certificates, and configuration.

What Gets Backed Up

A V2RayTun backup includes:

ComponentContents
PostgreSQL databaseUsers, nodes, squads, hosts, traffic stats
CertificatesmTLS CA, panel, and node certificates
Configuration.env, Caddyfile, docker-compose.yml

Creating a Backup

Bash
v2raytunsetup backup

The backup is saved as a compressed archive in /opt/v2raytun/backups/:

Text
/opt/v2raytun/backups/backup-2025-06-10-143000.tar.gz

Automated Backups

Set up a cron job for daily backups:

Bash
crontab -e

Add the following line:

Text
0 3 * * * /usr/local/bin/v2raytunsetup backup --yes

This creates a backup every day at 3:00 AM.

Restoring from a Backup

Bash
v2raytunsetup restore /opt/v2raytun/backups/backup-2025-06-10-143000.tar.gz

What Happens During a Restore

  1. All running services are stopped.
  2. The database is dropped and recreated from the backup dump.
  3. Certificate files are restored to /opt/v2raytun/certs/.
  4. Configuration files are restored.
  5. Services are restarted.

After a restore, all nodes reconnect automatically using the restored mTLS certificates.

Migrating to a New Server

  1. Create a backup on the old server:
Bash
v2raytunsetup backup
  1. Copy the backup archive to the new server:
Bash
scp /opt/v2raytun/backups/backup-*.tar.gz root@new-server:/tmp/
  1. Install V2RayTun on the new server:
Bash
bash <(curl -fsSL https://raw.githubusercontent.com/v2RayTun/install-panel/main/install.sh)
v2raytunsetup install-panel
  1. Restore the backup:
Bash
v2raytunsetup restore /tmp/backup-*.tar.gz
  1. Update DNS records to point both domains to the new server's IP.

Retention

Backups are not automatically rotated. Clean up old backups periodically:

Bash
ls -lt /opt/v2raytun/backups/
rm /opt/v2raytun/backups/backup-OLD-DATE.tar.gz

Or add a cleanup step to your cron job:

Bash
find /opt/v2raytun/backups/ -name "*.tar.gz" -mtime +30 -delete