PDA

View Full Version : Backing up the /hack directory and all sub directories


gwgw45
12-03-2004, 04:46 PM
For some reason (probably dying HDD that I am planning to replace) I lost my hack directory completely. Is there anyway I can back it up for the future. Also, are there any other files or directiries I should back up?

Thanks all
G.

dommac2000
12-03-2004, 04:52 PM
Have a look at showthread.php?threadid=159558 (sorry can't post full URL)

gwgw45
12-03-2004, 04:59 PM
Thanks a lot Douggie, unfortunately I can't find the thread in question:-(

G.

dommac2000
12-03-2004, 05:01 PM
Try h t t p : / / w w w . tivocommunity.com/tivo-vb/showthread.php?threadid=159558

scgf
12-03-2004, 05:32 PM
What I do is use an ftp application to drag from the TiVo a copy of the /var/hack directory. I then store it on my Mac's hard drive.

Not sure how I would reinstate it if I lost network access to the TiVo though. At least I wouldn't lose all my hacks once I had restored net access.

gwgw45
12-03-2004, 06:40 PM
Originally posted by dommac2000
Try h t t p : / / w w w . tivocommunity.com/tivo-vb/showthread.php?threadid=159558

Thanks Dougie (notice just one g this time) :-)

gwgw45
12-03-2004, 06:41 PM
Originally posted by scgf
What I do is use an ftp application to drag from the TiVo a copy of the /var/hack directory. I then store it on my Mac's hard drive.

Not sure how I would reinstate it if I lost network access to the TiVo though. At least I wouldn't lose all my hacks once I had restored net access.

What command line do you use for this?

Thanks
G.

gwgw45
12-03-2004, 06:43 PM
Originally posted by scgf
What I do is use an ftp application to drag from the TiVo a copy of the /var/hack directory. I then store it on my Mac's hard drive.

Not sure how I would reinstate it if I lost network access to the TiVo though. At least I wouldn't lose all my hacks once I had restored net access.

Would you mind telling me what the command line was that you used?

Thanks
G

6022tivo
12-03-2004, 06:53 PM
http://www.tivocommunity.com/tivo-vb/showthread.php?threadid=159558

Is the thread.

The problem with the FTP method you use to drag the hack folder to the PC is that you will lose all the permissions on the files if you restored them (the chmod thingies).

I have not got my method to hand, but I run the gzip command or what even, it creates a compressed file of the hack folder including the permissions, then I ftp it to my pc. If any problems, ftp the gzip file back then expand it, all permissions intact.

scgf
12-04-2004, 04:50 AM
I hadn't thought of the permissions. I have just checked my backup and it looks like the permissions are intact - maybe because I use Mac OS X which is a Unix operating system.

So, if you don't use a Mac, ignore my advice!

gwgw45 - all I did was drag the /var/hack folder from the ftp gui window onto my Mac desktop.

Strange, isn't it, that the TiVo is essentially a Mac (at least in that it uses PPC architecture) and uses Unix, like the Mac, yet all the hacking we do has to be done on a PC using an alien architecture and using an Linux OS compiled for Intel. I suppose it has to do with the sheer numbers of PCs around.

gwgw45
12-04-2004, 05:34 AM
Originally posted by 6022tivo
http://www.tivocommunity.com/tivo-vb/showthread.php?threadid=159558

Is the thread.

The problem with the FTP method you use to drag the hack folder to the PC is that you will lose all the permissions on the files if you restored them (the chmod thingies).

I have not got my method to hand, but I run the gzip command or what even, it creates a compressed file of the hack folder including the permissions, then I ftp it to my pc. If any problems, ftp the gzip file back then expand it, all permissions intact.

Thanks, whatn you say makes a lot os sense! If you were to come across your method I would be delighted to see it:-)

Cheers
GWGW45

6022tivo
12-04-2004, 05:18 PM
TO BACKUP

tar -cvh hack | gzip > hack.tar.gz

from the /var directory..
This created a 2.5MB file in the var directory which I ftp'd to my PC.


Now if all fails I can ftp the file back to /var and then run

gzip -d hack.tar.gz
cpio -H tar -i < hack.tar

from the /var directory and all should be back to normal after a restart??

gwgw45
12-04-2004, 05:25 PM
Originally posted by 6022tivo
TO BACKUP

tar -cvh hack | gzip > hack.tar.gz

from the /var directory..
This created a 2.5MB file in the var directory which I ftp'd to my PC.


Now if all fails I can ftp the file back to /var and then run

gzip -d hack.tar.gz
cpio -H tar -i < hack.tar

from the /var directory and all should be back to normal after a restart??

Thank you so much, really, really appreciated!

GWGW45

ericd121
04-02-2005, 06:36 AM
I'm using
0 05 * * 1 tar -cvh hack | gzip > hack.tar.gz
in my TiVos' crontabs (to back up the hack dir) and checking today, I've found the hack.tar.gz file, dated last Monday, is empty on both TiVos.

I haven't a clue what's happening; does anyone else?

crontab is in /var/hack/etc and is running the delmanual command without a hitch.

Is this one of those Read Only - Permissions - type things? :confused:

[Edit]
I just ran the command manually, and it does appear the TiVo need to be set to Read/Write

[Double Edit]
It appears I was looking in the wrong dir...
The file is present and correct in the /var dir and not in the /var/hack dir which was the one being backed up... :o

6022tivo
04-02-2005, 01:16 PM
Hello

I hadn't thought of adding it to cron..

I back it up in case the var directory is cleared, like tivo does when having a paddy. But I ftp it to the pc as the backup file would be deleted also when var is cleared.

Can the backup file be saved to anywhere, or are all the other locations read only??

Can it be backed up via cron to a PC?? Shared drive etc??.

bobones
04-02-2005, 02:17 PM
You could create a scheduled job under windows (control panel) that downloads the backup file using ftp. For example:

c:\backup\tivobak.bat
ftp -s:tivo.ftp tivo
c:\backup\tivo.ftp
bin
cd /var
get tivobak.tgz

6022tivo
04-02-2005, 02:41 PM
Fantastic......

Now have edited cron to include the backup, have used your time Eric of 0 05 * * 1
Is this 5 past midnight every Monday????? if not please let me know and I will change it?

Also have a script running everytime my PC boots to backup data folders to a network standalone hard drive, have just added what you said bobbones, cheers.

Had to alter the ftp script and added a couple of blank lines as it requires you to press enter twice to bypass the login password that is not needed, also added QUIT at the end to release back to the bat file.


Thanks again, now a happier bunny, cheers Phil.

CarlWalters
04-03-2005, 06:03 AM
You could create a scheduled job under windows (control panel) that downloads the backup file using ftp. For example:

c:\backup\tivobak.bat
ftp -s:tivo.ftp tivo
c:\backup\tivo.ftp
bin
cd /var
get tivobak.tgz

Excellent :D

I've now done this so that I should have an automated backup of /var/hack once per week. I had to download tar from
here (http://tivo.samba.org/download/mbm/bin/) and I made a couple of changes to the two script files. First to supress the ftp login and then to quit at the end so my files look like

@echo off
rem file to get the TiVo /var/hack backup file which is /var/hack.tar.gz
rem /var/hack.tar.gz is created automatically once per week (on Monday)
rem using the cron crontab entry
rem # m h dom mon dow command
rem 0 05 * * 1 tar -cvh /var/hack | gzip > /var/hack.tar.gz&
ftp -n -s:tivo.ftp tivo



bin
cd /var
get hack.tar.gz
quit

Restorer
04-03-2005, 08:00 AM
Can someone please tell me what is tar, where can I get it and which directory does it go in? When I try to run 6022's command line (tar -cvh hack | gzip > hack.tar.gz) I get "tar:command not found" although it does create an (empty) hack.tar.gz file.

dommac2000
04-03-2005, 11:47 AM
Can someone please tell me what is tar, where can I get it and which directory does it go in? When I try to run 6022's command line (tar -cvh hack | gzip > hack.tar.gz) I get "tar:command not found" although it does create an (empty) hack.tar.gz file.

Tar is an archiver. CarlWalters posted the link in the previous post - http://tivo.samba.org/download/mbm/bin/

The tar program should go somewhere in your path (usually /var/hack/bin) and made executable.

Restorer
04-03-2005, 12:41 PM
CarlWalters posted the link in the previous post - http://tivo.samba.org/download/mbm/bin/

Ah, missed that. Thanks for the gen. Working fine. Now I gotta find out about this cron thing.

lcsneil
04-03-2005, 02:25 PM
Well I tried all that and when I ran

tar -cvh hack | gzip > hack.tar.gz

It reports back segmentation fault and terminates. (Also says that if I dont put any parameters either).

Anyone any ideas (have set tar permission to 755 btw)

Neil

6022tivo
04-03-2005, 03:27 PM
Are you running it from the var directory and have you called your hack directory hack??

Permissions probably have to be set.

lcsneil
04-03-2005, 03:38 PM
Running it from var directory

I do indeed have a directory called /var/hack - which runs loads of stuff and the TAR in var/hack/bin is set to permissions 755

(for info var/hack is set to 755 as well)

Neil

ericd121
04-04-2005, 06:54 AM
Now have edited cron to include the backup, have used your time Eric of 0 05 * * 1
Is this 5 past midnight every Monday????? if not please let me know and I will change it?Close, it's 5:00am every Monday.

5 past midnight would be
05 0 * * 1

I put this comment in crontab to remind me.

# m h dom mon dow command
# m=minute h=hour dom=dayofmonth mon=month dow=dayofweek
# dayofweek is the day number of the week where
# 0 (or 7) are Sunday, 1 Monday, 5 is Friday, 6 Saturday.

6022tivo
04-04-2005, 07:34 AM
Fantastic advice eric, I will add this into my crontab file.

I am glad I rewrote a module for tivoweb so I could easily edit the crontab file and save it with the browser. So have added..

I will also post the link below which makes it wasy to create the values for the kick off times..

http://www.clockwatchers.com/cron_tool.html

ericd121
04-04-2005, 04:20 PM
To Carl (or anyone else willing to answer) A couple of questions.

Question 1

I see from your comment
rem 0 05 * * 1 tar -cvh /var/hack | gzip > /var/hack.tar.gz&
that you have backgrounded the backup.

Is this necessary (he asked, not really sure what backgrounding is, or does :rolleyes: )?

Question 2

I have two TiVos (lucky me :up: ).

Do you think I should set up two Windows Scheduled Tasks, or one with this adaption of your code@echo off
ftp -n -s:tivo.ftp tivo1
ftp -n -s:tivo.ftp tivo2
bin
cd /var
get hack.tar.gz
quit
Ooh! I thought of a third question.

Question 3

Where does hack.tar.gz end up on the PC?

6022tivo
04-04-2005, 04:26 PM
Re Q1, Same as you fella??. Backgrounding??

Maybe someone will pop along and answer..

Q2 The one should be ok..
"I have two TiVos" ohhhh get you!!

Q3 Ends up in the same directory as the FTP script.

misterbleepy
04-04-2005, 04:35 PM
Q3 Ends up in the same directory as the FTP script.

You could use:

lcd <desired pc directory name>

to change to a different directory on the PC before downloading the file
(lcd=local change directory)

lcsneil
04-05-2005, 01:47 PM
No one have any ideas why I get Segmentation fault then??

:(

Neil

dommac2000
04-05-2005, 01:58 PM
No one have any ideas why I get Segmentation fault then??

Have you tried re-downloading the tar file and made sure that you've ftp'd it in binary mode?

lcsneil
04-05-2005, 02:07 PM
Weird - I had done.

Just did it again and it's fine now.

Curiouser & curiouser said Alice......


Ta

Neil

bobones
04-05-2005, 04:21 PM
To answer eric's questions.

1. You don't need to background programs started by cron as cron itself does the backgrounding (Backgrounding simply means that the shell starts the program but doesn't wait for it to complete before continuing).

2. For 2 tivos you could use 2 different ftp scripts taking advantage of the fact that "get foo bar" retrieves the file "foo" but renames it "bar" when it has been retrieved.

3. hack.tar.gz ends up in the current directory of the batch process that started the ftp command which you can change when you define the scheduled task. You can also change directory within the ftp script using lcd. I would probably just use "get hack.tar.gz tivo1.tar.gz" and "get hack.tar.gz tivo2.tar.gz" in the ftp scripts.

thepatrician
04-06-2005, 12:55 PM
Fantastic advice eric, I will add this into my crontab file.

Have you (or anyone else for that matter) run the backup fully using cron, as I have a problem doing so.

When run via cron, not all files are backed-up - some files and folders within /var/hack are missing. If I do the same command (tar -cvh /var/hack | gzip > /var/hack.tar.gz) via a bash prompt, everything gets backed-up.

Anyone have an idea why this may be happening?

Cheers,
thepatrician.

AMc
01-12-2006, 06:16 AM
This thread was the best that I found in a search.

Sorry for the networking newbie question...

I get
bash-2.02# tar -cvh hack | gzip > hack.tar.gz
bash: tar: command not found

I guess means I need to download tar but the link (http://tivo.samba.org/download/mbm/bin/) in this post by CarlWalters is dead
http://www.tivocommunity.com/tivo-vb/showthread.php?p=2743491&&#post2743491

Where do I get tar from now?

6022tivo
01-12-2006, 06:23 AM
This thread was the best that I found in a search.

Sorry for the networking newbie question...

I get
bash-2.02# tar -cvh hack | gzip > hack.tar.gz
bash: tar: command not found

I guess means I need to download tar but the link (http://tivo.samba.org/download/mbm/bin/) in this post by CarlWalters is dead
http://www.tivocommunity.com/tivo-vb/showthread.php?p=2743491&&#post2743491

Where do I get tar from now?

Hi, it was in my /var/hack/bin directory??

I think it was part of a large file I unzipped when installing my net card ages ago???


It is too large to post, so I have saved it from my tivo to my webspace.

Get it at

NOW GONE

You will have to right click and save as (no extension)

for a limited time

You will have to chmod it I think

AMc
01-12-2006, 07:41 AM
Hmmm looks like there was something wrong with my /var/hack/bin directory.
Rerunning the steps here has put it back with tar installed.
http://tivo.stevejenkins.com/network_cd.html#_Toc101001776

Thanks for the quick response 6022tivo

ericd121
01-12-2006, 03:35 PM
It appears my post above was correct after all.

I'm using
0 05 * * 1 tar -cvh hack | gzip > hack.tar.gz
in my TiVos' crontabs (to back up the hack dir) and checking today,
I've found the hack.tar.gz file, dated last Monday, is empty on both TiVos.

I haven't a clue what's happening (again); does anyone else?

crontab is in /var/hack/etc and is running the delmanual command without a hitch.

Is this one of those Read Only - Permissions - type things? :confused:

Sadly, I am looking in the right dir...

Glesgie
01-13-2006, 05:29 AM
You may have accidentally ftp'd tar in ASCII mode, instead of binary.
That would result in a corrupted file.

Make very sure that the file sizes on the PC and the tivo are identical.

Glesgie
01-13-2006, 12:01 PM
Sorry, answered the wrong question.

If tar works from the bash prompt but not in cron then
you probaly have tar in a directory that is NOT in the PATH defined in crontab.
Either use the absolute path in crontab (eg/var/hack/bin/tar) or add
trhe directory to the PATH line.