TABI CLOUD
VPS

VPS swap and backups: set up swap, then back up with tar and rsync

6 min read · Updated October 2026 · By Tabi Cloud

Two small habits save many VPS headaches: swap for memory spikes, and backups for everything else. Commands are for Ubuntu and Debian and may vary on other distributions. Tabi Cloud has not stated that backups or snapshots are included in VPS plans, so make your own and keep a copy off the server.

Check for existing swap

  1. free -h
  2. swapon --show

If Swap shows 0, you have none.

Create a swap file

  1. sudo fallocate -l 2G /swapfile
  2. sudo chmod 600 /swapfile
  3. sudo mkswap /swapfile
  4. sudo swapon /swapfile
  5. echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

If fallocate fails, use sudo dd if=/dev/zero of=/swapfile bs=1M count=2048 instead. Swap is slower than RAM, so treat it as a safety net, not a replacement. You can lower eagerness with sudo sysctl vm.swappiness=10.

Back up with tar

tar bundles and compresses folders.

  1. tar -czf backup-$(date +%F).tar.gz /var/www /home/deploy/mybot
  2. ls -lh to check the size
  3. tar -tzf backup-DATE.tar.gz | head to peek inside

To restore, run tar -xzf backup-DATE.tar.gz -C /restore-folder.

Copy off the server with rsync

Keeping backups only on the same VPS is risky.

  1. rsync -avz /var/www/ user@otherhost:/backups/www/
  2. rsync -avz user@yourvps:/home/deploy/ ./local-backup/ to pull to your own computer

Add --delete only when you want the copy to mirror deletions, and test with --dry-run first.

Databases

Copying live database files is not reliable, so dump instead.

Automate with cron

  1. crontab -e
  2. Add 0 3 * * * tar -czf /home/deploy/backups/site-$(date +\%F).tar.gz /var/www

Cron needs the percent sign escaped as shown.

Tips

Need a hand? Reach us by Discord ticket or email.

Want your own server? Join our Discord and tell us the game. We set it up and send you the details. Need help with an error from this guide? Open a ticket there.

GET STARTED ON DISCORD

More guides

VPSWhat is a VPS and how is it different from shared hosting?VPSHow to choose a VPS plan: vCPU, RAM and diskVPSFirst steps on a new Linux VPS: SSH, updates, user and keys