Wiki > Backing up your slot's configuration and torrent files
While it's not easy to backup your entire slot without another server or computer with equal or greater storage, it may be desirable for you to have a backup of your slot's configuration (Plex library and plugins, autodl-irssi filters, cron jobs, etc.) and
.torrent files. Below is one way you can backup your slot's configuration and torrent files.
- Connect to your slot through SSH.
- Create a folder to store the backup.
- Make sure you have a scripts folder.
What to back up
The command to create a backup of your entire slot is:
tar -zcvf /home/user/backups/whatbox-backup.tgz /home/user/* /config/user/*
However, you'll most likely want to exclude some paths from the backup. Below are some examples of things you should exclude:
Your media files
You'll want to exclude
/home/user/files and any other media folders so you don't exceed your slot's storage because of the backup's file size.
You should safely exclude Plex's
Cache directory which will save space and time in the backup process, as recommended by Plex. This folder is located at
/home/user/Library/Application Support/Plex Media Server/Cache
Example backup command
After determining what you want to exclude, use the
--exclude flag to specify these paths. Here is an example command that employs this flag:
tar --exclude='/home/user/files' --exclude='/home/user/Library/Application Support/Plex Media Server/Cache' --exclude='/home/user/mnt' -zcvf /home/user/backups/whatbox-backup.tgz /home/user/* /config/user/*
Note: once you have your command, be sure you know what it does and try a test backup before proceeding. After running, you can:
- Check the size of your backup.
du -sh /home/user/backups/whatbox-backup.tgz
- List the contents of the archive without extracting it.
tar -tvf /home/user/backups/whatbox-backup.tgz
Specifying paths to back up instead of excluding
You can alternatively give
tar a list of specific paths you'd like to back up using the
-T flag instead of excluding paths:
Make a file to be used by the backup command.
Edit the file and enter the paths you want to back up.
Here is an example
/config/user /home/user/.bashrc /home/user/.config /home/user/.autodl /home/user/html /home/user/.irssi /home/user/.scripts /home/user/.ssh /home/user/Tautulli/config.ini /home/user/Tautulli/tautulli.db /home/user/tautulli_restart.cron /home/user/Library/Application Support/Plex Media Server
Save the file with
Then, using the
-Tflag, the new
tarcommand would look something like this:
tar --exclude='/home/user/Library/Application Support/Plex Media Server/Cache' -zcvf /home/user/backups/whatbox-backup.tgz -T /home/user/.scripts/backup_paths.txt
For this example, we still had to exclude Plex's
Cachedirectory as it is inside the main Plex directory.
Transferring the backup
rsync -avz --progress /home/user/backups/whatbox-backup.tgz username@some_server_or_ip:/path/to/backup/dir/
The breakdown of the rsync command is as follows:
rsync - Runs the syncing program rsync
a - archive mode; equals -rlptgoD (no -H,-A,-X)
v - increase verbosity
z - compress file data during transfer
--progress - show transfer progress
Creating a backup script
Combining the above
rsync commands, you can create a backup script.
Create a new script file.
Edit the file and enter the text below.
#!/bin/bash # backup cron jobs crontab -l > /home/user/.config/crontab.txt # create backup archive echo "tar command goes here" # backup to another server echo "rsync command goes here"
echolines with your backup and transfer commands from above.
Save the file with
Make the script executable.
chmod +x /home/user/.scripts/whatbox-backup.sh
You can run the script by entering:
Automating backups with cron
You can tell cron to automagically run your script at a specified time.
Open your crontab file.
Add the following text to the bottom of the file.
# Whatbox backup script @weekly /bin/bash /home/user/.scripts/whatbox-backup.sh > /dev/null 2>&1
Note (1): You can replace the
@weeklypart with whatever frequency you'd like. See the cron wiki for more information.
Note (2): Each run of the script will overwrite the previous backup, so you will always have the latest one.
Save the file with