Copy data off a broken server
As long as SSH still answers, pull the data out before you try any repair: dump databases first, then copy files with <code>rsync</code> or a <code>tar</code> stream over SSH to another machine. Start with what you cannot recreate. If the server no longer answers, a backup add-on restore through a support ticket is the remaining route.
Recovery and troubleshooting guide, updated 2026-12-03
Why copy data before repairing?
Repairs change the disk. A file system check, a package reinstall or a forced remount can each make a partly readable system unreadable. Copying first means that whatever happens next, you already hold the content that matters. It also gives you freedom: with the data safe, a rebuild becomes a simple, fast choice instead of a risky one.
Do the copy from the outside, pulling to another machine you control: your computer, another server, or a storage box. Writing a new archive onto the failing disk itself adds load and may fail halfway.
What should you copy first?
Rank by how hard each item is to recreate, not by size:
- Databases: they change constantly and their files on disk are not safe to copy while the database runs.
- User uploads and generated content:
/var/www/*/uploads, application data folders, mail stores. - Secrets and configuration:
/etc(nginx, ssh, systemd units, cron),.envfiles, TLS keys you cannot reissue quickly. - Container volumes:
/var/lib/docker/volumes, or the bind mount folders your compose files use. - Application code: usually last, since it should already live in a Git repository.
Skip caches, logs older than you need, node_modules, package caches and system binaries; reinstalling those is faster than copying them.
How do you dump databases safely?
Dump from inside the server and stream the result straight to your machine, so nothing extra lands on the failing disk:
# MySQL or MariaDB
ssh root@203.0.113.10 "mysqldump --all-databases --single-transaction --routines --events" | gzip > all-mysql.sql.gz
# PostgreSQL
ssh root@203.0.113.10 "sudo -u postgres pg_dumpall" | gzip > all-pg.sql.gz
# A database running in Docker
ssh root@203.0.113.10 "docker exec db pg_dump -U app appdb" | gzip > appdb.sql.gz--single-transaction gives a consistent dump of InnoDB tables without locking them. For SQLite, use sqlite3 app.db ".backup /tmp/app.db" and copy that file, rather than copying the live database file. Check every dump: zcat all-pg.sql.gz | tail should end with normal SQL, not a truncated line.
How do you pull files with rsync?
rsync is the best tool for a shaky server because it resumes: run the same command again after a disconnect and it continues where it stopped.
rsync -aHAX --numeric-ids --info=progress2 --partial \
-e "ssh -o ServerAliveInterval=15" \
root@203.0.113.10:/var/www/ ./rescue/var-www/-a keeps permissions and times, -HAX keeps hard links, ACLs and extended attributes, --numeric-ids keeps owners as numbers so they match after a restore, and --partial keeps half-copied large files for the next attempt. The trailing slash on the source copies the content of the folder rather than the folder itself.
If the server is overloaded, be gentle: add --bwlimit=20m to cap the speed, and prefix the remote side with nice and ionice using --rsync-path="nice -n 19 ionice -c3 rsync".
When is tar over SSH better?
For millions of small files, a single tar stream is often faster than rsync because it avoids per-file round trips:
ssh root@203.0.113.10 "tar -C / -czf - etc var/www home" > rescue.tar.gz
tar -tzf rescue.tar.gz | headThe downside is that a dropped connection means starting over, so use it for folders you can copy in one go. To exclude junk, add options such as --exclude=var/www/*/cache before the folder list. scp also works for single large files such as a dump you already made: scp root@203.0.113.10:/root/db.sql.gz .. For whole disks, see cloning a disk over SSH.
What if the disk went read-only?
A file system the kernel remounted read-only is still readable, which is all you need for copying. rsync and tar read without writing. Things that need writes do fail: a database dump through a running database may break if the database itself cannot write its own files. In that case stop the database and copy its data folder as files instead, for example /var/lib/postgresql or /var/lib/mysql, with the same major version ready on the receiving side.
Do not try mount -o remount,rw before the copy is done; the details are in checking and repairing a file system. If some files return I/O errors, rsync reports them and carries on; note the list and fetch those from a backup later.
How do you check that the copy is complete?
Do a second rsync pass with --dry-run --itemize-changes; an empty result means both sides match. For extra certainty on critical folders, compare checksums with --checksum on that dry run, which reads every file on both sides. Count files on both sides with find /var/www -type f | wc -l. Finally, test the important part: load a dump into a local database, open a few uploaded images, start the app from the copied config.
What if the server no longer answers at all?
Without SSH there is no path to the disk from the outside, since the console has no rescue system. Try the triage in when a server will not boot first; a power cycle sometimes buys enough time for a final copy.
If the backup add-on was active, open a ticket naming the server and the day you want back. With seven daily copies you can pick a day before the trouble started. Once restored and running, copy the data off right away before investigating further. Without a backup, your own off-server copies are the remaining source; the backups guide shows how to set them up so the next incident is calmer.
Questions about this guide
Can I copy the raw database files instead of dumping?
Only with the database stopped, and only to the same major version. A dump is portable and safer.
Which is faster, rsync or tar?
tar for many small files in one stream, rsync for large files and unstable connections because it resumes.
Does copying data count towards my traffic?
Data leaving the server counts as outgoing traffic; incoming traffic is free. A rescue copy is usually small against the monthly amount.
Can support copy the data for me?
Support does not log in to your system. They can restore the backup add-on to a day you name, after which you copy what you need.
Where should the copy go?
Anywhere off the server: your computer, another server, or a storage target reached with rsync or rclone.
Should I copy /etc entirely?
Yes, it is small and useful as a reference, but do not restore it wholesale onto a new image; pick the files you need.