
rsync copies folders between two computers over SSH and, on later runs, sends only what changed. It is the most used tool for taking a copy of your VPS to somewhere else, which is the golden rule of any backup: a copy on the same disk is lost with it (backing up a VPS: snapshots or files). The typical command is rsync -avz /var/www/ user@other-server:/backups/www/. On an unmanaged VPS these copies are yours.
Step by step
|
|
|
|
|
The options you will use
| Option | What it does |
| -a | Archive mode: keeps permissions, owners, dates and links, and goes into subfolders. |
| -v | Shows what it is doing. |
| -z | Compresses while sending. Saves bandwidth, costs processor; for files already compressed (images, video) it does little. |
| -n / --dry-run | Rehearses without copying. Always use it before a dangerous option. |
| --exclude='cache/' | Leaves out what is not worth copying (caches, temporary files). |
| --delete | Deletes at the destination what no longer exists at the source. It makes a mirror, and mirrors the deletions too. |
| -P | Shows progress and lets you resume an interrupted large file. |
| The slash at the end of the path changes the result. /var/www/ (with a slash) copies the folder’s contents; /var/www (without) copies the whole folder into the destination. Getting it wrong creates an extra folder, or mixes files where they should not be. Rehearse with -n. |
| --delete propagates mistakes. If you deleted a file by accident at the source, the mirror deletes it at the destination on the next run, and the copy no longer has it. For a copy that protects you from deletions, keep several older copies (dated folders) rather than a single mirror. |
| Databases are not copied with rsync while they are working. Export them first (mysqldump and pg_dump) and copy the exported file. Use a user only for backups, instead of root, and limit what it can do at the destination. |
|
Want to know what your VPS plan includes for backups? Tell us the service name and we will confirm. Open a support ticket |
|
SEE ALSO Backing up a VPS: snapshots or files Automatic backups of your own application |
RECOMMENDED PRODUCT Web hosting with cPanel Domain and SSL included, daily backups and the panel you already know. from 5.940,00 Kz/mo (3-year plan, with coupon) See plans |
- 0 Users Found This Useful











