Restore a SnapShooter WordPress backup to Different Location
Our one-click restore process is designed to get your existing site back up and running asap. However, you may want to restore a backup to a different location. We explain how you can do this and create a script to get started.
First, you need to grab the URLs SnapShooter shows you for backups. These have an expiry date of one hour and should be kept private, as anyone with the link (within the one hour window) can download your backup.
Install the script on your server
nano /tmp/snapshooter-wp-restore
#!/bin/bash # © 2017-2021 SnapShooter Limited.echo "# © 2017-$(date +"%Y") SnapShooter Limited."echo "# Terms and Conditions https://snapshooter.com/snapshooter-terms-and-conditions"echo "" echo "Which Directory do you want the backups to restore to (/var/www/sitename)"read wp_direcho Backups will be restored to $wp_direcho "" echo "Please give us the download url for the MYSQL database"read wp_mysql_urlecho "" echo "Please give us the download url for the ASSETS database"read wp_assets_urlecho "" rm /tmp/restore.tar.gzcurl $wp_assets_url -o /tmp/restore.tar.gz tarDirectory=$( cat /tmp/restore.tar.gz | gunzip - | tar -tvf - | head -1 | rev | cut -d " " -f 1 | rev)strip=$(awk -F"/" '{print NF-1}' <<< "${tarDirectory}")echo Found the DIR in tar to be $tarDirectory echo Restoring site nowcd $wp_dircp $wp_dir/wp-config.php /tmp/wp-config.php.backcat /tmp/restore.tar.gz | tar -zxf - --strip=$striprm $wp_dir/wp-config.phpmv /tmp/wp-config.php.back $wp_dir/wp-config.php echo ""rm /tmp/restore.tar.gz echo Restoring Database MYSQL_USERNAME=$(cat wp-config.php | grep DB_USER | cut -d \' -f 4)MYSQL_PASSWORD=$(cat wp-config.php | grep DB_PASSWORD | cut -d \' -f 4)MYSQL_HOST=$(cat wp-config.php | grep DB_HOST | cut -d \' -f 4)MYSQL_PORT=$(php -r "echo explode(':','$MYSQL_HOST')[1] ?? 3306;")MYSQL_DATABASE=$(cat wp-config.php | grep DB_NAME | cut -d \' -f 4) curl $wp_mysql_url --output - | gunzip - | mysql -u $MYSQL_USERNAME -p$MYSQL_PASSWORD -h $MYSQL_HOST -P $MYSQL_PORT $MYSQL_DATABASE echo Backup Restored
Give the script execute permissions
chmod +x /tmp/snapshooter-wp-restore
Finding your download URLs
SnapShooter will generate download links for all the files in your backup. We generate them with a signature to keep them secure, which also defaults too one per hour.
Find the backup you wish to restore and press the Manage button.
You will notice you have two backup files for a WordPress single backup, if you're doing multi-backup Wordpress or GridPane backups you will see many files and will need to find the matching site names (you can sort by name or size).
For the files you need to press copy link, and it will generate you a unique download link (1 hour)
Run the Script
Now you are ready to run the script on the server you wish to restore on
cd /tmp./snapshooter-wp-restore
When you run the script you will get three prompts
The directory of the WordPress site you wish to overwrite e.g /var/www (no trailing slash)
The SnapShooter URL for the Database
The SnapShooter URL for the file system assets
You can now login to your site. You may need to manually correct the WP config for the correct URL.
Thank you for helping us improve!