Howto Backup and Restore a Plesk Domain From The Command Line
This HOWTO shows how to use the Plesk command line utilties to backup and restore a single domain. This can be useful, among other reasons, as a way to move a site between servers (though now they have the Migration Manager for that) or as a way to make a final backup of a domain before removing it (though to be safe you should make other backups and have regular periodic backups as well).
BACKUP
Set a domain name as a variable in your shell (not really required, just makes the rest harder to screw up if you copy and paste from this howto):
DOMAIN_NAME=example.com
Go to the directory where plesk keeps the dumps
# cd /var/lib/psa/dumps/$DOMAIN_NAME
Create a file with the description. even if you don’t care about the description, the file needs to exist.
# echo “description goes here” > description.txt
Run the backup:
# /usr/local/psa/admin/bin/domain_bu –backup –domain-name $DOMAIN_NAME –dump-file $DOMAIN_NAME.domain_dump –desc-file description.txt
Note that the shell prompt will be returned to you before the backup is completd. you can watch for the backup to be finished with this command (after waiting a moment or two for backup_restore.log to be created if it wasn’t there already):
# tail -f backup_restore.log
When you see the text “Single domain backup is successfully completed.†(or something to that effect, depending on your version), the backup is completed.
RESTORE
To restore again with the backup, or restore on another server:
- Add the domain under the desired client in plesk (the domain has to exist in plesk to continue).
- Copy the .dump file to other server’s /var/lib/psa/dumps/[DOMAIN_NAME] directory.
- Set a domain name, client login and ip address the site should use as variables in your shell (not really required, just makes the rest harder to screw up if you copy and paste from this howto):
DOMAIN_NAME=example.com
CLIENT_LOGIN=myclient
IP_ADDRESS=1.2.3.4
Go to the dumps directory where you had copied the dump to:
# cd /var/lib/psa/dumps/$DOMAIN_NAME
Run the restore command:
# /usr/local/psa/admin/bin/domain_bu –restore –domain-name $DOMAIN_NAME –client-login $CLIENT_LOGIN –domain-ip $IP_ADDRESS –dump-file $DOMAIN_NAME.domain_dump
If you get errors when restoring related to unmatched cert, see the instructions here: http://forum.plesk.com/showthread.php?s=&threadid=12274
MIGRATION TIPS
If this backup/restore was to move a domain to a new server, here are some useful tips:
- Set the TTL for the zone to something low like 600 more than a day in advance.
- After the move, you can add something like this to the .htaccess file of the site on the old server (for web requests that still make it there):
RewriteEngine on
RewriteRule (.*) http://domain.com.previewhostname/$1 [P]Where domain.com.previewhostname would be where the site can be viewed before dns is changed.
Print This Post
Blogsphere: TechnoratiFeedsterBloglines
Bookmark: Del.icio.usSpurlFurlSimpyBlinkDigg
RSS feed for comments on this post | TrackBack URI for this post
Related Post:
- Change Reseller’s Primary Domain
- Howto Easy Though Poor DNS Setup
- Howto Remove The Logging of Lame-Server
- DNS Command for Troubleshooting
- Howto Setup SSL Certificates for Mail Services
