You finished Part 3 - Installing Plex, Rclone and Plexdrive, now let's restore your personal settings.
In part 4 and part 5 of the first tutorial you went through the trouble of setting up an API at Google, configuring Rclone and Plexdrive, and setting up your mount scripts. Of course, once you have done that, restoring should be as easy as running a single line script... right? Right!
Creating the script
Here is how you do that. As before, create a new (empty) file in Notepad++. Make sure you change the bottom bar to show "Unix (LF)".
Paste the following into your file
#!/bin/bash
# Restore Rclone config
mkdir -p ~/.config/rclone
cat > ~/.config/rclone/rclone.conf << EOF
Paste contents of your rclone config file here (replace this text)
EOF
# Restoring scripts backup
cd /tmp
sudo rclone copy Gdrive:/Backup/VPSBackup.tar.bz2 /tmp --checksum --drive-chunk-size=64M -v
sudo -s tar -xvf /tmp/VPSBackup.tar.bz2 -C /
sudo rm /tmp/VPSBackup.*
cd ~
# Restoring services
sudo mkdir /mnt/Plexdrive
sudo systemctl enable rclone.service
sudo systemctl enable plexdrive.service
sudo systemctl enable plexpy.service
sudo systemctl enable plexproxy.service
sudo systemctl daemon-reload
sudo chown plexuser:nogroup -R /opt/plexpy
sudo systemctl start plexpy.service
chmod +x ~/bin/*
# Creating backup cron
(crontab -l 2>/dev/null; echo "5 1 * * Sun /home/plexuser/bin/plex-backup > /dev/null 2>&1") | crontab -
# Reboot
read -e -p "Reboot (Y/n)? " -i "Y" choice
case "$choice" in
y|Y ) sudo reboot;;
* ) echo "Manual reboot required.";;
esac
# Cleaning up
sudo rm /tmp/restore-scripts
cd ~
# End message
echo ""
echo "================================================"
echo " Please reboot! Then restore your Plex database "
echo "================================================"
echo ""
# To run this file copy the line below without the # and paste in PuTTY
# sudo wget https://www.dropbox.com/s/yourpersonallink/yourfilename?dl=0 -O /tmp/restore-scripts && sudo chmod +x /tmp/restore-scripts && /tmp/restore-scripts
The first step in the process is to restore Rclone, which can then be used to restore the rest.
Getting the Rclone config
The information you need is in the Rclone configuration script. Which, luckily, is included in the backup you created in part 1 of this tutorial. But that's all zipped up and stored on Google - the easiest way to extract that information is from there.
Visit https://drive.google.com and open the Backup folder. Then right-click the file VPSBackup (or whatever you named your file in part 1), and download it to your local computer.
Go to the folder where you downloaded the file. right click to select 7-Zip and click "Extract Here" (or if you wish, extract to a new folder named VPSBackup.tar):
This will create a new file named "VPSBackup.tar". Repeat the process of extracting that as well and you will see a list of the folders you backed up.
Descend into home / yourusername / .config / rclone - you should see the rclone.conf file. Right-click that one, and choose "Edit with Notepad++".
Copy the entire content of that file to your clipboard (Ctrl-C). Then go back to the script you created above and paste the entire content between the two EOF statements (Ctrl-V). Make sure you replace the text that is currently there! It will probably look like somewhat like this:
It's okay if you can't read it... your VPS can and that's the main thing!
Adapting the script
Make sure you change the remaining red text to reflect your own setup!
You can adapt this script to suit your own situation. For example, if you don't run Tautulli or don't use CloudFlare, you can remove the lines "sudo systemctl enable plexpy.service" and "sudo systemctl enable plexproxy.service", respectively.
Again, the purpose of this tutorial is to restore your VPS to your personal and unique setup.
Running the script
Once adapted to your needs, you can run the script on each consequent installation and you will never have to mess with configuring Rclone and Plexdrive ever again.
You're ready for the final Part 5 - Restoring the Plex database to restore Plex to its former glory.
Comments
Post a Comment