Ideas - scripts that can help you migrate data from your old server to your new shiny Plexguide (with gdrive) | PlexGuide.com

Ideas scripts that can help you migrate data from your old server to your new shiny Plexguide (with gdrive)

  • Stop using Chrome! Download the Brave Browser via >>> [Brave.com]
    It's a forked version of Chrome with native ad-blockers and Google's spyware stripped out! Download for Mac, Windows, Android, and Linux!
Welcome to the PlexGuide.com
Serving the Community since 2016!
Register Now

Simpleton

Active
Original poster
Donor
Sep 25, 2018
38
5
Like most here, I find Plexguide to be awsome! I am struggeling to get my data moved thou. I wan't it done in such a way that I don't get downtime on my currently running and working plex server with local storage.

Challanges:
1. I have x TB of data on harddrives. I can't touch those until the new plexguide server is online AND configured. Which will take days at best.
2. I don't have spare harddrives to just copy everything to new disks and install plexguide.

Suggestion:
Build a set of migration scripts in plexguide.
- rsync over ssh. Let plexguide ask for user and password.
- let plexguide ask you to, point to you movies, series, music, books or other such directory on old server.
- let the script then sync 1 file from your old server, to your gdrive move folder for that category.
- let the script wait for that file to get uploaded and removed by the pg move functionality.
- let the script sync the next file.

I realize this will take more time than needed since nothing will be uploading in the periods where you are syncing from current server to the new one. BUT it will be automatic, so who cares that it takes longer? And you will only need a staging area on the new server that can fit the biggest single file on your old one.

Can anyone build such a script?
 
Last edited:

itsmylife10173

Citizen+
Donor
Feb 4, 2019
22
5
Here is a bash script I used to move all my media, My media was on a windows server 2016 storage space but Im sure this could be modified to work with other things. Its kinda messy but it did work :)

Bash:
#!/bin/bash

#number of movies to copy at once
number_movie_copies=3

#number of tv shows to copy at once
number_tv_copies=1

#directory of stuff thats done
done_dir="/mnt/unionfs"

#directory containing movies on windows server
win_movie_dir="Movies"

#directory containing tv shows on windows server
win_tv_dir="TV Shows"

#directory on linux server we are mounting the win network volume on
local_windir="/media/mount"

#local temporary directory to copy from windows server to linux server
local_tempdir="/mnt/largevolume/tmpcopydir"

#local directory that other scripts upload from
moving_dir=$(echo $(cat /var/plexguide/server.hd.path)/move)

#file size to look for when seeing if everything was copied/deleted
check_file_size="101M"

#loop speed var
loop_speed_var="30"

#pulling credentials for windows mount
win_user=$(head -1 /home/plexadmin/wincreds.txt)
win_pass=$(tail -1 /home/plexadmin/wincreds.txt)

#windows share address
win_share="//10.73.73.2/d"


#mount windows volume
mount -t cifs -o username=$win_user,password=$win_pass $win_share $local_windir
echo mounted volume

#setting ifs because while reads were too hungry
ifsstore=$IFS
IFS=$'\n'

#main loop, if there is nothing to do it checks every loop_speed_var seconds
while :;do
        check_empty_dir=$(find $moving_dir/ -type f -size +$check_file_size | wc -l)
        if (($check_empty_dir == 0));then
                #get list of stuff already copied to google or copying
                done_movie_list=$(find "$done_dir/movies/" -maxdepth 1 -type d| cut -d/ -f5)
                done_tv_list=$(find "$done_dir/tv/" -maxdepth 1 -type d| cut -d/ -f5)

                #get full list of movies and tv shows on windows volume
                movie_list=$(find "$local_windir/$win_movie_dir/" -maxdepth 1 -type d)
                tv_list=$(find "$local_windir/$win_tv_dir/" -maxdepth 1 -type d)

                #prune the done lists from our working lists
                for i in $(echo "$done_movie_list");do
                        movie_list=$(echo "$movie_list" | grep -v "$i")
                done
                for i in $(echo "$done_tv_list");do
                        tv_list=$(echo "$tv_list" | grep -v "$i")
                done

                #grab what movies/shows are being copied in this loop iterations
                copy_movie_list=$(echo "$movie_list" | tail -$number_movie_copies)
                copy_tv_list=$(echo "$tv_list" | tail -$number_tv_copies)

                #check if both lists ended up empty, that means we are done and exit
                done_check_movie=$(echo "$copy_movie_list" | wc -l)
                done_check_tv=$(echo "$copy_tv_list" | wc -l)
                if (($done_check_movie == 0)) && (($done_check_tv == 0));then
                        #all done
                        umount "$local_windir"
                        IFS=$ifsstore
                        exit
                fi

                #making dirs since they get moved at end of loop iteration
                mkdir -p "$local_tempdir/tv" "$local_tempdir/movies"

                #copying from windows volume to local temp dir for movies
                if (($done_check_movie > 0));then
                        for i in $(echo "$copy_movie_list");do
                                cp -rfv "$i" "$local_tempdir/movies/"
                        done
                fi

                #copying from windows volume to local temp dir for tv shows
                if (($done_check_tv > 0));then
                        for i in $(echo "$copy_tv_list");do
                                cp -rfv "$i" "$local_tempdir/tv/"
                        done
                fi

                #moving temp dir contents to the folder being pulled by other scripts
                #this is done so we know win->linux copies are finished
                mv -fv $local_tempdir/tv/* $moving_dir/tv/
                mv -fv $local_tempdir/movies/* $moving_dir/movies/
        fi
        echo -e "#########################\nSAFE TO KILL FOR $loop_speed_var SECONDS\n#########################"
        sleep "$loop_speed_var"
done
 

Recommend NewsGroups

      Up To a 58% Discount!

Trending