*Cube-Host– full cloud services!!
Backups should be automatic, predictable, and testable. The best backup is the one you can restore quickly. In this guide you’ll set up automatic backups using built-in tools on Linux (cron + tar/rsync) and Windows (Windows Server Backup + Task Scheduler).
These methods are ideal for production on Linux VPS and Windows VPS hosted on reliable VPS hosting, where you want a clean baseline without third-party backup software.
This is the most universal “built-in” method for a Linux VPS: create an archive locally and push it offsite via rsync over SSH.
sudo mkdir -p /backup
sudo chmod 700 /backup
Create /usr/local/bin/backup.sh:
sudo nano /usr/local/bin/backup.sh
Example script (adjust paths and DB backup to your stack):
#!/usr/bin/env bash
set -euo pipefail
TS="$(date +%F_%H-%M)"
DEST="/backup/backup-${TS}.tar.gz"
LOG="/backup/backup.log"
# Example: database dump (optional)
# mysqldump -u root -p'PASSWORD' --single-transaction --routines --triggers --events yourdb > /backup/db-${TS}.sql
tar -czf "$DEST" \
/var/www \
/etc \
/home
echo "$(date -Is) Created $DEST" >> "$LOG"
Make it executable:
sudo chmod +x /usr/local/bin/backup.sh
sudo crontab -e
Daily backup at 03:00:
0 3 * * * /usr/local/bin/backup.sh >/dev/null 2>&1
Never store the only backup on the same VPS. Push to another server/storage (second VPS). Example:
rsync -az /backup/ user@REMOTE_SERVER:/remote-backup/
Add to cron at 03:30:
30 3 * * * rsync -az /backup/ user@REMOTE_SERVER:/remote-backup/ >/dev/null 2>&1
Delete backups older than 14 days:
find /backup -type f -name "backup-*.tar.gz" -mtime +14 -delete
Add cleanup to cron at 04:00:
0 4 * * * find /backup -type f -name "backup-*.tar.gz" -mtime +14 -delete >/dev/null 2>&1
# List archive contents
tar -tzf /backup/backup-YYYY-MM-DD_HH-MM.tar.gz | head
# Restore a file (example)
tar -xzf /backup/backup-YYYY-MM-DD_HH-MM.tar.gz -C /tmp ./etc/hosts
On a Windows VPS, you can use built-in Windows Server Backup (WSB) and schedule jobs via Task Scheduler. This covers files, volumes, and (optionally) System State.
Install-WindowsFeature Windows-Server-Backup
Example: backup drive C: to a dedicated backup disk (replace target). For System State, add -systemState where appropriate.
# Example: volume backup
wbadmin start backup -backupTarget:E: -include:C: -quiet
Create a scheduled task that runs under SYSTEM with highest privileges. Action example:
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "wbadmin start backup -backupTarget:E: -include:C: -quiet"
Automatic backups using built-in tools are a strong baseline: Linux cron + tar/rsync and Windows Server Backup + Task Scheduler cover most real-world cases. For stable performance and predictable backup windows, run them on a properly sized Linux VPS or Windows VPS with reliable storage on VPS hosting.