Backup & Restore
Back up and restore V2RayTun panel data — database, certificates, and configuration.
What Gets Backed Up
A V2RayTun backup includes:
| Component | Contents |
|---|---|
| PostgreSQL database | Users, nodes, squads, hosts, traffic stats |
| Certificates | mTLS CA, panel, and node certificates |
| Configuration | .env, Caddyfile, docker-compose.yml |
Creating a Backup
v2raytunsetup backupThe backup is saved as a compressed archive in /opt/v2raytun/backups/:
/opt/v2raytun/backups/backup-2025-06-10-143000.tar.gzAutomated Backups
Set up a cron job for daily backups:
crontab -eAdd the following line:
0 3 * * * /usr/local/bin/v2raytunsetup backup --yesThis creates a backup every day at 3:00 AM.
Restoring from a Backup
v2raytunsetup restore /opt/v2raytun/backups/backup-2025-06-10-143000.tar.gzWhat Happens During a Restore
- All running services are stopped.
- The database is dropped and recreated from the backup dump.
- Certificate files are restored to
/opt/v2raytun/certs/. - Configuration files are restored.
- Services are restarted.
After a restore, all nodes reconnect automatically using the restored mTLS certificates.
Migrating to a New Server
- Create a backup on the old server:
v2raytunsetup backup- Copy the backup archive to the new server:
scp /opt/v2raytun/backups/backup-*.tar.gz root@new-server:/tmp/- Install V2RayTun on the new server:
bash <(curl -fsSL https://raw.githubusercontent.com/v2RayTun/install-panel/main/install.sh)
v2raytunsetup install-panel- Restore the backup:
v2raytunsetup restore /tmp/backup-*.tar.gz- Update DNS records to point both domains to the new server's IP.
Retention
Backups are not automatically rotated. Clean up old backups periodically:
ls -lt /opt/v2raytun/backups/
rm /opt/v2raytun/backups/backup-OLD-DATE.tar.gzOr add a cleanup step to your cron job:
find /opt/v2raytun/backups/ -name "*.tar.gz" -mtime +30 -delete