Plex Backup - Single Command Issue

Status
Not open for further replies.

Kamikaze321

Dabbler
Joined
Nov 30, 2015
Messages
11
Hi,

I'm trying to find an efficient way of backing up all my jails, specifically Plex. I found this guide on the forum
https://forums.freenas.org/index.ph...-sickrage-plex-freenas-9-3.35444/#post-271268

The first post in this thread suggested running the plex backup as 2 separate commands.
Code:
cd /mnt/VolumeData/jails/plexmediaserver_1/var/db/
tar cvfz /mnt/VolumeData/Backup/FreeNAS/Plex/plexdata.tar.gz plexdata


running these 2 commands separately works fine. it takes about 10 mins but it works. (of course I modified the paths slightly to match my dataset names, etc.)

further down in the thread it is suggested to combine these 2 commands into 1 to make it possible to backup with a cron job. I would like to do this but I'm running into an issue when I try to run this command:

Code:
tar -cvfz /mnt/VolumeData/Backup/FreeNAS/Plex/plexdata.tar.gz /mnt/VolumeData/jails/plexmediaserver_1/var/db/plexdata/


when I run this commands it looks like its working, it starts backing up all the 1000's of plex data files and runs for about 10 mins but then gets stuck on this error:
JPi5xmn.jpg


and it never ends up creating the "plexdata.tar.gz" file in my backup dataset

Does anyone know what I'm doing wrong to cause this error to occur?

these are the exact commands i'm typing:
http://pastebin.com/9agnWpHz
 

Allan Wilmath

Explorer
Joined
Nov 26, 2015
Messages
99
When you put multiple commands on the same line they are executed in order. So you would do 'cd /mnt/VolumeData/jails/plexmediaserver_1/var/db/ && tar cvfz /mnt/VolumeData/Backup/FreeNAS/Plex/plexdata.tar.gz plexdata'

What makes it work is the '&&' which allows you to place multiple commands at once, they are still executed in order thought ass if they are entered separately.
 

Kamikaze321

Dabbler
Joined
Nov 30, 2015
Messages
11
Thank! just tested that and it worked.

Bonus Question:
is there a way I can modify that command to somehow concatenate the current date/time to the end of the tar.gz file so every time I run the command it won't overwrite the previous file?
 

Allan Wilmath

Explorer
Joined
Nov 26, 2015
Messages
99
'cd /mnt/VolumeData/jails/plexmediaserver_1/var/db/ && tar cvfz /mnt/VolumeData/Backup/FreeNAS/Plex/plexdata.tar.gz plexdata`date +"%Y-%m-%d-%h-%m"`'

That should work for you. btw, be careful because there are both ' and ` in that command. You can find ` on the tilde key, above the tab key on the left of the keyboard.

Or simply cut and past.
 

Kamikaze321

Dabbler
Joined
Nov 30, 2015
Messages
11
'cd /mnt/VolumeData/jails/plexmediaserver_1/var/db/ && tar cvfz /mnt/VolumeData/Backup/FreeNAS/Plex/plexdata.tar.gz plexdata`date +"%Y-%m-%d-%h-%m"`'

That should work for you. btw, be careful because there are both ' and ` in that command. You can find ` on the tilde key, above the tab key on the left of the keyboard.

Or simply cut and past.

I didn't have any luck with that one
drxEoMV.jpg

its looks like there might be a minor mistake with the placement of apostrophes / whatever this ` is called. I'm not good enough at command syntax to figure out how to make that run properly
 
Last edited:

Kamikaze321

Dabbler
Joined
Nov 30, 2015
Messages
11
Remove the quotes ( ' ) from the start and finish of the command.

Oh.. right. I tried that before to but also didn't work. it looks like its failing to create the destination directory.
B2dFhiq.jpg


I guess this error might be more helpful though.

EDIT:

NVM I got it to work. I just needed to shuffle the order little bit.
The commands below will append the date at the end of the tar.gz file (I just need to remove the date from the file prior to a restore if necessary)

Code:
'cd /mnt/VolumeData/jails/plexmediaserver_1/var/db/ && tar cvfz /mnt/VolumeData/Backup/FreeNAS/Plex/plexdata.tar.gz`date +"%Y-%m-%d-%h-%m"`' plexdata
 
Last edited:

kamhoe

Dabbler
Joined
Mar 30, 2016
Messages
26
Oh.. right. I tried that before to but also didn't work. it looks like its failing to create the destination directory.
B2dFhiq.jpg


I guess this error might be more helpful though.

EDIT:

NVM I got it to work. I just needed to shuffle the order little bit.
The commands below will append the date at the end of the tar.gz file (I just need to remove the date from the file prior to a restore if necessary)

Code:
'cd /mnt/VolumeData/jails/plexmediaserver_1/var/db/ && tar cvfz /mnt/VolumeData/Backup/FreeNAS/Plex/plexdata.tar.gz`date +"%Y-%m-%d-%h-%m"`' plexdata

I have no problem when I run 2 separate commands. However I run 1 command and the response is: Cannot stat: No such file or directory

Code:
'cd /mnt/VolumeData/jails/plexmediaserver_1/var/db/ && tar cvfz /mnt/VolumeData/Backup/FreeNAS/Plex/plexdata.tar.gz`date +"%Y-%m-%d-%h-%m"`' plexdata
[/QUOTE]

Can someone fix it for me? I am new to FreeNAS! Thanks!
 

depasseg

FreeNAS Replicant
Joined
Sep 16, 2014
Messages
2,874
I have no problem when I run 2 separate commands. However I run 1 command and the response is: Cannot stat: No such file or directory
you added the date variables to plexdata, instead of the tar.gz file.
 

kamhoe

Dabbler
Joined
Mar 30, 2016
Messages
26
you added the date variables to plexdata, instead of the tar.gz file.
What would be the correct command if I would like to have a date on the filename too? I am poor with the FreeNAS script! Thanks!
 

kamhoe

Dabbler
Joined
Mar 30, 2016
Messages
26
What would be the correct command if I would like to have a date on the filename too? I am poor with the FreeNAS script! Thanks!
Oh, this way?

'cd /mnt/VolumeData/jails/plexmediaserver_1/var/db/ && tar cvfz /mnt/VolumeData/Backup/FreeNAS/Plex/plexdata.tar.gz plexdata`date +"%Y-%m-%d-%h-%m"`'
 

depasseg

FreeNAS Replicant
Joined
Sep 16, 2014
Messages
2,874
tar [options] name_of_file_to_be_created_datastamp.tar.gz name_of_file_or_folder_to_be_tar'd
 

depasseg

FreeNAS Replicant
Joined
Sep 16, 2014
Messages
2,874
Oh, this way?

'cd /mnt/VolumeData/jails/plexmediaserver_1/var/db/ && tar cvfz /mnt/VolumeData/Backup/FreeNAS/Plex/plexdata.tar.gz plexdata`date +"%Y-%m-%d-%h-%m"`'
The answer is up above in this thread. I believe you even quoted it in post #8.
 

kamhoe

Dabbler
Joined
Mar 30, 2016
Messages
26
Is working now! No symbol ' at the front and at the end! Why people put that?
 
Last edited:

depasseg

FreeNAS Replicant
Joined
Sep 16, 2014
Messages
2,874
Yeah, those get a little confusing. It is how the command line interpreter knows what to do. The CLI needs to know if you want the filename to actually contain the characters date +%Y-%m or did you want it to calculate the values and substitute the results.
 

depasseg

FreeNAS Replicant
Joined
Sep 16, 2014
Messages
2,874
And there are 3 different types ", ', and `.
 
Status
Not open for further replies.
Top