Skip to main content

Part 1 - How to restore your VPS in minutes

If you are anything like me, you like to play with your VPS. Perhaps you like to reinstall it occasionally, or change to a new provider, or repair a corrupted server. I personally reinstall my VPS so often, that I can follow the guide almost blindly and be back to the original state in less than an hour.

Still, I tried to think of ways to speed that up even further. What if I could create a true turnkey restore script, catered to my installation? That is why I came up with these backup and restore scripts and have decided to share them with you all.

First, it is important to note that you need to know how to setup your VPS in the first place. After all, you don't want to restore to my installation, you want to restore to your installation. I assume that you have followed and fully understand the Infinite Plex tutorial from start to finish.

Remember, you need to have created and run the Plex backup script from Part 6 - because this tutorial will proceed where that guide left off.

What you need

You will probably need to install a few additional apps on your local computer:

  • I highly recommend you install Notepad++ if you are using Windows.
  • For opening compressed files, I use 7-Zip which is free and open source as well.
  • I personally use a free Dropbox account for online storage (the few scripts that you need are tiny). Unfortunately, Google won't work, because you can't directly link to a file.

If you are a Mac user, you will need to find the equivalent of the above apps.

Creating a backup of your settings

The first step in creating a turnkey restore option is to create a backup of all your modified files.

The backup script, created in PuTTY under your own user:

nano ~/bin/vps-backup

Paste the following:


# Stopping services
sudo systemctl stop plexpy.service
sudo service plexmediaserver stop

# Creating backup
sudo -s tar -cvjf /tmp/VPSBackup.tar.bz2 \
  ~/* \
  ~/.config/rclone/rclone.conf \
  /etc/systemd/system/rclone.service \
  /etc/systemd/system/plexdrive.service \
  /etc/systemd/system/plexpy.service \
  /etc/systemd/system/plexproxy.service \
  /opt/plexpy/config.ini \
  /opt/plexpy/plexpy.db \
  /root/.plexdrive/config.json \

# Starting services
sudo service plexmediaserver start
sudo systemctl start plexpy.service

# Copying to Gdrive and cleaning up
sudo rclone copy /tmp/VPSBackup.* Gdrive:/Backup -v --checksum --drive-chunk-size=64M
sudo rm /tmp/VPSBackup.*
echo Done!

Save with Ctrl-O, Enter, then Ctrl-X. Make the script executable:

chmod +x ~/bin/vps-backup

This will create a backup of your most important VPS configuration files and copy it to a folder named "Backup" in Google. You can run the script by typing "vpsbackup". Done? Great! You're halfway there.

Because you have followed the entire "Infinite Plex on a VPS" tutorial, by now I assume you will be able to figure out which parts to edit or remove if you haven't installed Tautulli (PlexPy), for example, or if your configuration deviates from the initial guide.

Your backup will be online in Google:\Backup and the file name will be VPSBackup.tar.bz2.

Note: in this tutorial I'm not covering backing up or restoring your websites, from the tutorial Creating a Website on a VPS. I'm assuming the above script mentions enough details to add those files yourself, should you wish to.

Now that you have backed up both your Plex database and your most important files, let's get on with the first restore script in Part 2 - Updating the VPS.