I switched a few weeks ago from a dedicated server to a VPS. Now that everything is working well on the VPS I would like to shutdown the dedicated server and close my account with the hosting company.
For peace of mind and in order to be more safe I would like to do a full backup of the server before stopping it.
The best would be a backup that I could browse if I find that I need a something in the backup.
What would be the best solution from command line?
Update :
Medium : Network
The best tool to use for this is probably dump, which is a standard linux tool and will give you the whole filesystem. I would do something like this:
This will do a file system dump of / (make sure you don't need to dump any other mounts!), compress it with gzip and ssh it to a remote server (backupserver.example.com), storing it in /backup/. If you later need to browse the backup you use restore:
Another option, if you don't have access to dump is to use tar and do something like
But tar does not handle changes in the file system as well.
If you want to backup from Linux to Linux I wouldn’t use dump, because it’s inconvenient when you need to access something inside the backup file. Just using
rsync
over SSH to do a full system backup should be fine in most cases:This will keep everything important and let you browse the backup without additional steps.
What medium are you going to be storing the backup on? If you're backing up over the network I would sshfs/nfs mount my destination on the source server and run something like:
Note that has not been tested, just my general thinking you may want to exclude more or less than that.
I use the command described above from pehrs, but modified for ftp use. Crontab sample:
upload.x contains ftp credentials and rules for upload:
Note 1: lftp may cause high CPU usage when destination is unreachable trying to reconnect. Because many hosting VPS's may be reset in such cases, I suggest to monitor CPU load to kill lftp process preventing your server shutting down by the host owner. An example for load average >1.33 for processes lftp (and dropbox). Unfortunately, I do not remember the source of initial code, thanks to somebody:
Crontab
*/5 * * * * /home/cms/cron/loadmon.sh
Note 2: dump utility may not work on OpenVZ VPS or some other virtual servers.
have you heard of Bacula?