I have rewritten a script I found on a forum to my own needs working with rclone to googledrive.
In short term what it does it. After a new Ubuntu 16.04LTS install I execute my script. It install all the current programs I have running on the server. It downloads the scripts I have encrypted on my googledrive, ssh keys … scripts , configs… everything. Maybe not the BEST script , and the best way of doing it , but its working for me as it should . ( My first modifed script so… )
But im kinda missing a backup / restore function to Plex.
I want to implement your guide to my script .
Lets say I want to have the script called plexbackup.sh I can run via crontab.
#!/bin/bash
sudo systemctl stop plexmediaserver.service
cd /var/lib/plexmediaserver
sudo tar cfz /nas/tmp/PlexBackup.tar.gz ./Library
echo “Backup of Plexmediaserver is complete”
Would that work for the backup? I know you wrote root shell, but will this work when im logged in as user and executing the script?
Then I will have the restore script made as well,but that script needs to be execute in my Install.sh script
I had some server crashes over time, so I wanted to make a script that reinstall my entire server as it was before it died .
That information lives on plex.tv
And it is tied to the machine ID, which is stored in the Preferences.xml
which should already be covered by the backup script, if I read it correctly.
If I may teach a little bit about “dot” and “dot dot” ?
Dot and DotDot are “current directory relative” addressing shortcuts.
“dot” (.) - this, the current, directory.
“dot dot” (…) - this directory’s parent directory.
Using ./Library notation is largely for tar’s benefit.
Looking inside the tar file, all the names will begin with ./
This guarantees all the files are rooted in the new ‘current’ directory when extracting.
Primary example of how this “slides uphill”
cd /var/lib/plexmediaserver
tar cf - ./Library | ( cd /home/plexdata ; tar xf - )
What does that do?
sets the current directory to “/var/lib/plexmediaserver”
In one command it:
a. Creates a tar file but, instead of writing to a named file, sends it to stdout
b. Creates a pipe to connect the stdout of the first part to the stdin of the second part
c. The second part spawns a subshell which executes two commands: Change directory & extracts from the tar file being streamed through stdin
The TL;DR - It is the fastest and easiest way to clone your entire Plex metadata library to a new location (/home/plexdata in this case)
These shortcuts had their roots in Multics because, in those days, teletype machines were “beyond painful” to type on. We needed an easier way. “Dot” and “Dot Dot” were the answer.
Unix came from Multics
BSD Unix came unto being when AT&T couldn’t get Unix version 4 done in time & on budget
MS-DOS borrowed from Unix.
MacOS is rooted in BSD Unix.
Linux is the ‘fresh free spin’ of the entire OS without the entire AT&T encumbrance