# Backing up the /hack directory and all sub directories



## gwgw45 (Nov 25, 2004)

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 (Jun 2, 2002)

Have a look at showthread.php?threadid=159558 (sorry can't post full URL)


----------



## gwgw45 (Nov 25, 2004)

Thanks a lot Douggie, unfortunately I can't find the thread in question:-(

G.


----------



## dommac2000 (Jun 2, 2002)

Try h t t p : / / w w w . tivocommunity.com/tivo-vb/showthread.php?threadid=159558


----------



## scgf (Oct 24, 2000)

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 (Nov 25, 2004)

> _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 (Nov 25, 2004)

> _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 (Nov 25, 2004)

> _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 (Oct 29, 2002)

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 (Oct 24, 2000)

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 (Nov 25, 2004)

> _Originally posted by 6022tivo _
> *http://www.tivocommunity.com/tivo-vb/showthread.php?threadid=159558
> 
> Is the thread.
> ...


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 (Oct 29, 2002)

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 (Nov 25, 2004)

> _Originally posted by 6022tivo _
> *TO BACKUP
> 
> tar -cvh hack | gzip > hack.tar.gz
> ...


Thank you so much, really, really appreciated!

GWGW45


----------



## ericd121 (Dec 12, 2002)

I'm using 
*0 05 * * 1 tar -cvh hack | gzip > hack.tar.gz* 
in my TiVos' *crontab*s (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*? 

[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...


----------



## 6022tivo (Oct 29, 2002)

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 (Jan 22, 2004)

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 (Oct 29, 2002)

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 (Oct 17, 2001)

bobones said:


> You could create a scheduled job under windows (control panel) that downloads the backup file using ftp. For example:
> 
> c:\backup\tivobak.bat
> 
> ...


Excellent 

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 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 (Jan 6, 2002)

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 (Jun 2, 2002)

Restorer said:


> 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 (Jan 6, 2002)

dommac2000 said:


> 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 (Jun 18, 2002)

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 (Oct 29, 2002)

Are you running it from the var directory and have you called your hack directory hack??

Permissions probably have to be set.


----------



## lcsneil (Jun 18, 2002)

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 (Dec 12, 2002)

6022tivo said:


> 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 (Oct 29, 2002)

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 (Dec 12, 2002)

*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  )?

*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 (Oct 29, 2002)

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 (Mar 11, 2002)

6022tivo said:


> 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 (Jun 18, 2002)

No one have any ideas why I get Segmentation fault then??



Neil


----------



## dommac2000 (Jun 2, 2002)

lcsneil said:


> 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 (Jun 18, 2002)

Weird - I had done. 

Just did it again and it's fine now. 

Curiouser & curiouser said Alice......


Ta

Neil


----------



## bobones (Jan 22, 2004)

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 (Jan 25, 2003)

6022tivo said:


> 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 (Mar 22, 2002)

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 (Oct 29, 2002)

AMc said:


> This thread was the best that I found in a search.
> 
> Sorry for the networking newbie question...
> 
> ...


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 (Mar 22, 2002)

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 (Dec 12, 2002)

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' *crontab*s (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*? 

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


----------



## Glesgie (Feb 3, 2003)

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 (Feb 3, 2003)

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.


----------

