# ARGH - whats happened to my TiVO?



## ptruman (Jan 8, 2003)

Tivoweb isn't working.
I can telnet in, but I get this error :

bash: /var/hack/scripts/makero.sh: No such file or directory

TiVo: {/var/tmp} # ls
bash: ls: command not found
TiVo: {/var/tmp} #

Now, thats NOT good...ls does work under tivosh....

/var/hack has completely gone. WTF?! Any ideas?

mount shows :

/dev/hda4 on / type ext2 (ro)
/dev/hda9 on /var type ext2 (rw)
/proc on /proc type proc (rw)

Help?!


----------



## ColinYounger (Aug 9, 2006)

Sounds like your TiVo has spotted some kind of filesystem problem and cleared the /var partition. It does this to protect itself from bad software updates and other things.

The solution is to restore /var/hack from a backup if you were lucky enough to do one, or re-install your hacks.


----------



## ptruman (Jan 8, 2003)

ColinYounger said:


> Sounds like your TiVo has spotted some kind of filesystem problem and cleared the /var partition. It does this to protect itself from bad software updates and other things.
> 
> The solution is to restore /var/hack from a backup if you were lucky enough to do one, or re-install your hacks.


Hmm, I think I had a tarfile (and it may not have been all of /var/hack) but can't remember where I hid it. If I don' t have a backup, is there a generic "tar" I can nab from somewhere?


----------



## blindlemon (May 12, 2002)

Exactly. Your /var has been wiped.

This happens sometimes - unfortunately - so you need to restore it from a backup if you have one. If you don't, then everything you need, including a script to automatically re-install it, can be found in twinst.zip


----------



## ptruman (Jan 8, 2003)

Cheers


----------



## AWT (Aug 25, 2005)

I'd hate to have to recreate my var/hack - are there any simple options for creating, say, an on-TiVo backup somewhere else within the filesystem? 

I can't remember exactly but I'm guessing that Tracker writes its database in /var/hack somewhere? It's early days for me but I'd hate to lose the database, so that's another reason to back this up somewhere. Are there any cron'able backup scripts that folks here already use for this?


----------



## yungee (Dec 29, 2002)

I wrote something a while back that TARs it up into your active root folder.

Needs a few of the standard binaries (df, du, mkdir, mount), and another (mawk) that most people probably won't have so I included mawk in the .zip file.

I've written it to not create the TAR if it will leave less than 50Mb free on the root volume once written. This can be easily changed by editing the number in line 4 (The FREE_SPACE_WANTED variable)

Instructions:

Unzip into suitable folder. I suggest making "/var/hack/backup" for it
run it:

./backup_var-hack

The script will give you some useful feedback as it runs, and all going well you'll end up with a folder off the root called /hack_backup with a tar file in it containing /var/hack

Oh, and a copy of your "tar" executable will be placed in that folder too, 'cos if you lose /var/hack you'll be needing that back too!!  

Disclaimer: This script should not cause any damage but consider it beta until at least another couple of the more techy people on here give it a thumbs up. :up:


----------



## AWT (Aug 25, 2005)

Thanks for the script and supporting executables - I'll give it a whirl at the weekend and report back.

I'm no Linux hacker as such, but I like how you've written your script 'defensively' against low disk space situations. Adding the tar executable is a neat touch too!


----------



## cwaring (Feb 12, 2002)

Well I'm no 'techy' as far as Linux is concerned, but I can confirm that it works well enough. I ran it and ended-up with a 17mb file in the directory as stated.

One hiccup, though. The lines about "which: not found" and "cp: mssing destination file". Didn't stop it working but don't know if they were essential?


```
Welcome to the wonderful world of TiVo hacking :)
Filesystem on / set to READONLY - type rw to make READ/WRITE
TiVo: {/var/tmp} % rw
File system is now READ/WRITE.
TiVo: {/var/tmp} %
TiVo: {/var/tmp} % cd /var/hack/hackbackup
TiVo: {/var/hack/hackbackup} %
TiVo: {/var/hack/hackbackup} % ls
COPYING.mawk-1.3.3  README.mawk-1.3.3   mawk
README              backup_var-hack
TiVo: {/var/hack/hackbackup} %
TiVo: {/var/hack/hackbackup} % ./backup_var-hack
Root partition mounted is currently: /dev/hda4
Space free on root is 103055 Kb
Space used by /var/hack tree is 17717 Kb
Good ... /var/hack tree is smaller than root space free. Let's do this thing.
Making /hack_backup folder to put the tar file into
tar: Removing leading `/' from absolute path names in the archive
./backup_var-hack: which: command not found
cp: missing destination file
Try `cp --help' for more information.
TiVo: {/var/hack/hackbackup} %
```
Also, on a related subject, why can I download from the internet faster than I can download something from my TiVo (ie locally)?

From Internet: 220kb/s
From Tivo: 135kb/s

Not really bothered. Just curious


----------



## yungee (Dec 29, 2002)

Cheers, let me know how you get on.

I only bundled "mawk" as I already had the other files installed from the various "standard" binary packages.

However I am aware there isn't really such a thing as "standard" in this case, and if all the various supporting executables are a problem, I'll bundle all the executables it needs with it, and make the script run them from within it's own directory.

The script took a couple of minutes to write, then a couple of months to bother to comment, give some feedback while it's doing it's thang, and generally not make me too embarrassed to post it here!


----------



## yungee (Dec 29, 2002)

cwaring said:


> Well I'm no 'techy' as far as Linux is concerned, but I can confirm that it works well enough. I ran it and ended-up with a 17mb file in the directory as stated.
> 
> One hiccup, though. The line about "which: not found". Didn't stop it working but don't know if it was essential?


Good stuff, cheers for trying it Carl.

The "which" command is just used to identify where your "tar" command is, so the script will take a copy of that and plonk it in with the backup too, so you have all the stuff you need self contained for a recovery. (Then the copy command following only fails as it isn't given the source file from the output of "which")

I've attached "which" to this message. Unzip it and just pop it somewhere in your executables path. (/var/hack/bin whatever)


----------



## cwaring (Feb 12, 2002)

You're welcome, and ta muchly for the file. Oh, and sorry for editing after you quoted 

(Must get to bed sometime soon )


----------



## yungee (Dec 29, 2002)

I thought'd I'd knock up a quick companion batch file to allow anyone to easily transfer this TAR file over onto their PC for a belt and braces approach.

All you need to do is edit the IP address to match that of your Tivo in the batch file, then put the two files together in a folder and run it. The backup file will be pulled over into the same folder that the batch file resides in.

Note: This runs on your PC, not on the Tivo.


----------



## spid3r (Dec 14, 2002)

This has happened to my unit too. Coincidence? A royal pain in the arse...
I had been doing some electrical work at home so I kept turning off the power - maybe that screwed it.

I've put it all back now and I'm liking the new TivoWebPlus, but it took ages refreshing my Linux knowledge again. I'm also surprised that the standard Tivo-binaries pack doesn't include ps, tar, and nano. It's a quite a hassle finding them.


----------



## Prof. Yaffle (Aug 2, 2002)

yungee said:


> I thought'd I'd knock up a quick companion batch file to allow anyone to easily transfer this TAR file over onto their PC for a belt and braces approach.
> 
> All you need to do is edit the IP address to match that of your Tivo in the batch file, then put the two files together in a folder and run it. The backup file will be pulled over into the same folder that the batch file resides in.
> 
> Note: This runs on your PC, not on the Tivo.


Very nice. Thanks.

A quick question though. Is it possible to have either the backup file or the file transferred to PC given a date in the file or folder name? When I remember to do a backup I usually keep 3 or 4 previous backups in a folder with a name along the lines of hacks130407.tar. That way I can go back a couple of backups when things go really pear shaped (it's happened a time or two when messing about).

EDIT

I was originally trying to get the date using DOS in the batch file but couldn't figure out why it wouldn't work and then realised it was because of Vista permissions.

I've put get_tivo_tar in Program Files with a scheduled task to launch it each Sunday and then I've added



> for /f "tokens=1,2,3 delims=/ " %%i in ('date /t') do (set date=%%i%%j%%k)
> move c:\"program files"\get_tivo_tar\hacks.tar c:\users\karl\documents\tivo\hacks%date%.tar


to the get_tivo_backup.bat file which moves the backup file to my TiVo backup folder and renames it as hacks.tar with the current date after the hacks bit. Seems to work okay. Now to set a Cron job on TiVo and wait until Sunday.


----------



## Cainam (May 25, 2004)

Yungee, another :up: from me - great script.

What may be useful to include in the readme: the commands needed to upzip the tar file again on the tivo if you have to use it i.e. all the parameters needed for the tar command!


----------



## Prof. Yaffle (Aug 2, 2002)

Well it worked. My PC grabbed the backup that had been created by Cron and renamed it with the date in the filename. Automatic backups. Thanks!


----------



## ericd121 (Dec 12, 2002)

cwaring said:


> Also, on a related subject, why can I download from the internet faster than I can download something from my TiVo (ie locally)?
> 
> From Internet: 220kb/s
> From Tivo: 135kb/s
> ...


I'm guessing that you have a turbonet or terbonet card that only connects at 10Mb/s?

Maybe it's one of those bits/bytes things? 

Hey, talk about dumb and dumber!  
(Which one of us is which?)


----------



## cwaring (Feb 12, 2002)

ericd121 said:


> Hey, talk about dumb and dumber!
> (Which one of us is which?)


Where's the "I'm saying nothing!" smiley when you need it?


----------



## yungee (Dec 29, 2002)

Cainam said:


> Yungee, another :up: from me - great script.
> 
> What may be useful to include in the readme: the commands needed to upzip the tar file again on the tivo if you have to use it i.e. all the parameters needed for the tar command!


Cheers for the positive feedback guys.

I think I'll pull everything together over the next couple of days, including a restore script that gets dumped into /hack_backup, then start a top level thread for people that might have missed it tagged on the end of this one.

I'm confident now that it will pretty much work "out of the box" with a couple of extra binaries in the distribution.

Professor Yaffle ... I'll change my PC batch file to use your date modification too if you don't mind, as that's an excellent idea for historical backups.


----------



## Prof. Yaffle (Aug 2, 2002)

No probs :up: I'm using it on Vista but I've just had a look on XP and the date /t output is the same so it should be fine.


----------



## Prof. Yaffle (Aug 2, 2002)

Hmmm.... I've just noticed something odd with this when looking at one of my backups.

I was looking at todays file that my PC had grabbed and noticed it didn't have the most recent modules I've added in the week. Looking at the date of the last file created on TiVo it was when I'd last manually ran the script. It appears that backup_var-hack works when it runs from Bash but when it runs from Crontab it doesn't. I tried running it again but getting it to output to a log file as well and it seems to be falling over on the free space check and the Root partition mount check.



> /var/hack/backup/backup_var-hack: ./mawk: No such file or directory
> Root partition mounted is currently:
> /var/hack/backup/backup_var-hack: ./mawk: No such file or directory
> Usage: grep [OPTION]... PATTERN [FILE]...
> ...


Anyone any idea what's going wrong?


----------



## TCM2007 (Dec 25, 2006)

Total guess: Looks like the script uses an relative path (./mawk) which will try to run a file called mawk in the current directory. Trouble is, crontab won't have the same current directory.

Edit the script you are running so it uses absolute pathnames, ie /var/hack/mawk wor whatever it is.


----------



## Prof. Yaffle (Aug 2, 2002)

TCM2007 said:


> Total guess: Looks like the script uses an relative path (./mawk) which will try to run a file called mawk in the current directory. Trouble is, crontab won't have the same current directory.
> 
> Edit the script you are running so it uses absolute pathnames, ie /var/hack/mawk wor whatever it is.


That'd make sense. Thanks. I'll try altering that now.


----------



## TCM2007 (Dec 25, 2006)

The other thing which can cause problem like thet is if the file has soomehow got DOS line endings on it - open in joe and look for ^Ms,.


----------



## Prof. Yaffle (Aug 2, 2002)

I've just changed it to actual paths which has got it further along. That then caused problems with the tar and cp lines so I've changed those to actual paths as well. Just waiting for cron to kick in.


----------



## Prof. Yaffle (Aug 2, 2002)

Yeap, that seems to have fixed it. Thanks :thumbs:


----------

