On this page
- Why a file-level copy instead of a disk image?
- What should be prepared before copying?
- Which paths should be excluded?
- How do I copy the whole system with rsync?
- How do I keep several versions with Borg instead?
- How do I restore onto a freshly installed server?
- Which files come back, and which stay from the new install?
- How do I confirm the restored server works?
- What goes wrong during full restores?
- Questions
Why a file-level copy instead of a disk image?
A raw block image (for example with dd) of a disk that is mounted and in use captures a file system in mid-write, and our servers have no rescue boot or custom ISO to take the disk offline. A file-level copy made with rsync or Borg reads files through the running system, can skip what is not needed and restores onto a new server of any size. That makes it the practical way to keep a full copy of a VPS you manage yourself.
There are no snapshots on BitcoinVPS. If you want the provider to keep whole-server copies, the optional daily backup add-on costs 20% of the monthly plan price and is restored through a support ticket; the daily backups tutorial explains it. This guide covers the do-it-yourself route, which also suits moving to a different plan as in move to a larger plan.
What should be prepared before copying?
A target with enough space, root-to-target SSH access and consistent application data. The target can be a second server, a home machine or a Borg repository; it only needs SSH and rsync or Borg installed. Then:
- Dump databases to files (
pg_dumpall,mysqldump --all-databases --single-transaction) so the copy contains a clean export. - Record installed packages, which makes the restore far more reliable.
- Check used space with
df -h /andsudo du -xsh /var/* | sort -h.
# Ubuntu, Debian
dpkg --get-selections > /root/packages.list
apt-mark showmanual > /root/packages-manual.list
# Rocky Linux, AlmaLinux
dnf repoquery --userinstalled --qf "%{name}" > /root/packages-manual.list
cat /etc/os-release > /root/os-release.txtWhich paths should be excluded?
Skip pseudo file systems, temporary data and anything rebuilt automatically. Save this list as /root/full-excludes.txt:
/dev/*
/proc/*
/sys/*
/run/*
/tmp/*
/var/tmp/*
/mnt/*
/media/*
/lost+found
/swapfile
/var/cache/apt/*
/var/cache/dnf/*
/var/lib/docker/overlay2/*
/home/*/.cache/*The trailing /* keeps the empty directories themselves, which a restore needs as mount points. Docker layers are excluded because images can be pulled again; keep volumes under /var/lib/docker/volumes or, better, export container data separately.
How do I copy the whole system with rsync?
Run as root on the source and push to a folder on the target named after the server.
sudo rsync -aAXH --numeric-ids --delete -x \
--exclude-from=/root/full-excludes.txt \
-e "ssh -i /root/.ssh/backup_ed25519" \
/ root@198.51.100.24:/srv/full-copies/web1/-A and -X keep ACLs and extended attributes (including SELinux labels), -H preserves hard links, --numeric-ids stops owner names from being remapped, and -x stays on the root file system. The first pass copies everything; following runs only move what changed, as described in the rsync guide. A mirror like this holds just one version, so combine it with dated copies or Borg if you need history.
How do I keep several versions with Borg instead?
Borg stores deduplicated, encrypted archives of /, so you get weeks of full copies for little more space than one. With a repository prepared as in the BorgBackup guide:
sudo -E borg create --one-file-system --compression zstd,3 \
--exclude-from /root/full-excludes.txt \
::web1-full-{now:%Y-%m-%d} /
sudo -E borg prune --keep-daily 7 --keep-weekly 4Borg keeps owners, modes, ACLs and extended attributes by default. A restore extracts an archive into a staging folder exactly like an rsync copy.
How do I restore onto a freshly installed server?
Deploy a new server with the same operating system image and release as the copy (see deploy a server or reinstall an image), bring it fully up to date and reboot. Then restore in two stages: packages first, files second.
# Ubuntu, Debian: reinstall the same packages
sudo apt update && sudo apt full-upgrade
sudo xargs -a packages-manual.list apt-mark manual
sudo xargs -a packages-manual.list apt install -y
# Rocky Linux, AlmaLinux
sudo dnf upgrade --refresh
sudo xargs -a packages-manual.list dnf install -yThird-party repositories must be added back before their packages install; copy /etc/apt/sources.list.d, /etc/apt/keyrings or /etc/yum.repos.d from the copy first.
Which files come back, and which stay from the new install?
Pull configuration and data from the copy while protecting what belongs to the new machine: boot files, kernel modules, the file system table and network settings, since the new server has its own disk IDs and IP addresses.
sudo rsync -aAXH --numeric-ids \
--exclude=/boot --exclude=/etc/fstab \
--exclude=/usr/lib/modules --exclude=/lib/modules \
--exclude=/etc/netplan --exclude=/etc/network \
--exclude=/etc/NetworkManager/system-connections \
--exclude=/etc/machine-id --exclude=/etc/hostname --exclude=/etc/hosts \
--exclude=/var/lib/dpkg --exclude=/var/lib/rpm --exclude=/var/lib/apt \
root@198.51.100.24:/srv/full-copies/web1/{etc,home,root,srv,opt,var} /Package databases stay from the new install because the packages were reinstalled in the previous step. Software you built under /usr/local is not in that list; copy it with a separate run to /usr/ if you need it. On Rocky and AlmaLinux finish with sudo restorecon -Rv /. Import database dumps, then reboot and check services with systemctl --failed.
How do I confirm the restored server works?
Check boot, network, services and data in that order.
systemctl --failed
ip -br addr
sudo ss -tlnp
curl -I https://example.net --resolve example.net:443:127.0.0.1
sudo journalctl -p err -bThen point DNS at the new address (see DNS records) and keep the old server running until traffic has moved. Rehearse a restore once on a short-term server before you need it for real; that is the only way to know the copy is complete.
What goes wrong during full restores?
- Server unreachable after reboot: old network files or
/etc/fstabcame back. Since there is no browser console, the fix is a reinstall and a careful second attempt with the excludes above. - Services fail with permission errors: owner IDs differ; restore with
--numeric-idsafter the packages are installed so system users exist. - SELinux denials: relabel with
restorecon -Rv. - Missing disk space: the new plan must have at least the used space of the old one plus room to grow.
Questions about Full-disk image copies of a server
Can I restore onto a different distribution or release?
Not with a full copy. Configuration and libraries are tied to the release. Move data and settings by hand instead, or upgrade the old server first so both match.
Does BitcoinVPS offer snapshots?
No. The available server-side option is the daily backup add-on, restored by support ticket. Everything else is done inside your server with tools like rsync, Borg and rclone.
Should I copy SSH host keys?
Copying /etc/ssh/ssh_host_* keeps the server fingerprint, so clients do not warn after a move. Leave them out if you prefer a fresh identity.
How big is a full copy?
About the used space shown by df -h / minus the excluded paths. With Borg, later archives only add the changed data.
Can the copy go to object storage?
Yes, if you already have such storage: write a Borg or tar archive locally or to another server and ship it with rclone.