# Backing up /var/hack/



## PhilG (Jan 15, 2002)

OK, this should be easy - but it isn't 

I've created a directory called /var/backup/

I have a script called varhackbackup in /var/hack/ that looks like THIS:

#
#
tar -cvf /var/backup/varhackbackup.tar . 

I have chmod'd it so that it's executable

I run it with the command

/var/hack/varhackbackup > /var/log/varhackbackup.log

It SEEMS to work OK, but it always ends with

: No such file or directory
tar: Error exit delayed from previous errors

but a tar file IS created and there are no errors in the log file

What did I do wrong???

Thanks


----------



## verses (Nov 6, 2002)

I'm not 100% certain, but I think this relates to the fact that the script that's running the tar command is being run from within the directory that's being tarred.

If the tar file does indeed contain everything you expect it to and can be expanded correctly then I think I'd be tempted to ignore the message 

Ian


----------



## Dicko (Oct 10, 2005)

I think you should probably put a cd /var/hack in the script... Otherwise it will backup whichever directory you happen to be in when you run the script.

Richard


----------



## PhilG (Jan 15, 2002)

Dicko said:


> I think you should probably put a cd /var/hack in the script... Otherwise it will backup whichever directory you happen to be in when you run the script.


Good point!!

I wish I knew the syntax of tar so I could specify the directory (and subdirectories) to backup on the tar command itself

Hmm

Now the script says

#
#
cd /var/hack/
tar -cvf /var/backup/varhackbackup.tar .

and I get more errors when I execute it from /var/backup (I moved it out of /var/hack/)

TiVo: {/var/backup} % ./varhackbackup
: No such file or directoryack/
: No such file or directory
tar: Error exit delayed from previous errors
: command not found

???


----------



## Dicko (Oct 10, 2005)

Are you editing the file on your Tivo or making the changes on your PC and then transferring the file with FTP?

If it's the latter then it *might* be that you are transferring the script in binary mode rather than ascii.

R.


----------



## ColinYounger (Aug 9, 2006)

Phil:

tar -cvf tarname.tar /directory1 /directory2 /directory3

Will create a tarname.tar file with the contents of those three directories. Importantly in this case, they'll have the *fully qualified* filenames in them, so that when you need the files back, you can restore them to the same place.

So your script needs to say

tar -cvf /var/backup/varhackbackup.tar /var/hack /etc/rc.d/rc.sysinit.author

to back up your hacks, and (presumably) the calls to those hacks in rc.sysinit.author.

For your next project, you need to compress that tarfile.


----------



## PhilG (Jan 15, 2002)

Hmm

Now the script says

#
#
tar -cvf /var/backup/varhackbackup.tar /var/hack /etc/rc.d/rc.sysinit.author

and the errors are

tar: Removing leading `/' from absolute path names in the archive
: No such file or directoryc.d/rc.sysinit.author
tar: Error exit delayed from previous errors


Is Linux twitchy about blank lines??


----------



## PhilG (Jan 15, 2002)

anyone??


----------



## ColinYounger (Aug 9, 2006)

Sorry Phil - missed your reply.


> tar: Removing leading `/' from absolute path names in the archive


This is only info - the paths stored in the archive will be 'var/hack/blah' rather than '/var/hack/blah'. This is obviously something to do with the implementation of tar used.


> : No such file or directoryc.d/rc.sysinit.author


This suggests a typo in the command in the script - notice that the filename is malformed. Perhaps a tab rather than a space?

I have tried the command on my TiVo and it worked quite happily.


----------



## PhilG (Jan 15, 2002)

OK, let me attach the script I am using

Perhaps there is something odd about it that I am not seeing

(and on my Tivo it's called "varhackbackup" without the .txt extension...

Thanks - it's driving me crazy


----------



## ColinYounger (Aug 9, 2006)

Phil - if it's ok with you, I'll look at this tomorrow (Sun). Just letting you know I've seen your post.


----------



## PhilG (Jan 15, 2002)

'course - I wasn't being pushy (honest)


----------



## ColinYounger (Aug 9, 2006)

Phil - no offence taken - I was only letting you know that you're not ignored.

I'm afraid 'real life' has been in the way today, and I haven't held up my end of the bargain. I apologise and will be in the position to help on Tue. Assuming no catastrophes, I'll be back on this thread then. I'm really sorry.


----------



## mwillford (Jan 1, 2007)

I am trying to use tar to backup my hack directory as well (looks like version 3.5b was pushed to my S1 DTivo). My tarball has all the directories but no files and I am getting the following errors on almost all files

tar: /var/hack/tivowebplus/themes/rss-style.xsl: *file is unchanged; not dumped*

Any help would be appreciated.


----------



## Pete77 (Aug 1, 2006)

Phil,

The following things seem to be wrong with your script.

1. The first line should be just:-

#!/bin/sh

The next line should be

tar -cvf /var/backup/hackbkup.tar /var/hack /etc/rc.d/rc.sysinit.author 2>&1

Whereas you do not have the #!/bin/sh line to denote that this is a script file and you have split the command up on to 3 different lines, instead of having it on one line as is necessary. You need to shorten the backup file name to achieve this as I have done.

You also need to make the scrip executable as well as follows:-

cd /var/backup
chmod 755 hackbackup.sh

or whatever file name you have actually called it.

You should then be able to run it at the command prompt as follows:-

cd /var/backup
./hackbackup.sh

Hope this helps.


----------



## PhilG (Jan 15, 2002)

Oooohh

I assumed I could use # as a comment character

Looks like I can't - right THEY're gone

I still get this odd error though

: No such file or directoryc.d/rc.sysinit.author

Which seems like something odd is happening trying to add rc.sysinit.author to the tar


----------



## Pete77 (Aug 1, 2006)

PhilG said:


> Oooohh
> 
> I assumed I could use # as a comment character


You can use the # prefix as a comment line in respect of all subsequent lines in the file after the first line. All subsequent # prefixed lines will not be executed or taken into account in any way.

Its just that the first line of the file defines the type of file structure that is expected.

With respect to your other problem have you managed to get the whole command on to just one line in the script file yet, rather than having it splurged across several different lines? You should be able to achieve this if you shorten the name of the output tar backup file.

Also have you saved your script file in a Linux compatible text editor and not in Windows Notepad?

And did you make the script executable with chmod 755?


----------



## PhilG (Jan 15, 2002)

Pete77 said:


> With respect to your other problem have you managed to get the whole command on to just one line in the script file yet, rather than having it splurged across several different lines? You should be able to achieve this if you shorten the name of the output tar backup file.
> 
> Also have you saved your script file in a Linux compatible text editor and not in Windows Notepad?
> 
> And did you make the script executable with chmod 755?


Last question first, yes it IS executable

I did save it in a Linux friendly editor (I think) - certainly I use it to edit tcl scripts with impunity

In my editor, the command is ONE line.....


----------



## Pete77 (Aug 1, 2006)

My script file is as follows and works fine in creating the tar file:-

*#!/bin/sh
tar -cvf /var/backup/hackbkup.tar /var/hack /etc/rc.d/rc.sysinit.author 2>&1*


----------



## PhilG (Jan 15, 2002)

Remind me again what the "2>&1 " does??


----------



## Pete77 (Aug 1, 2006)

PhilG said:


> Remind me again what the "2>&1 " does??


It makes sure that the command in the script file is executed as you were expecting. 

I took it from the example of various suggested script files to be run by Cron written by others more expert than me in Linux/MFS.


----------



## ColinYounger (Aug 9, 2006)

2>&1 means that the output of errors ('output 2') will be put to the same place as standard output (output 1).

On Pete's line, it effectively does nothing as standard output is not being redirected to anything - errors and standard output will go to the console (screen).

You usually see it when we want to throw away the output from a command, like this:

```
somecommand >>/dev/null 2>&1
```
This puts standard output and error output to pseudo device 'null' (i.e. nowhere).


----------



## ColinYounger (Aug 9, 2006)

mwillford - what's the tar command you're using, please?


----------



## Pete77 (Aug 1, 2006)

ColinYounger said:


> On Pete's line, it effectively does nothing as standard output is not being redirected to anything - errors and standard output will go to the console (screen).
> 
> You usually see it when we want to throw away the output from a command, like this:
> 
> ...


Colin,

In view of your above comments do you think we should be putting *>>/dev/null 2>&1 &* at the end of all executable lines in .sh script files and in our rc.sysinit.author or rc.sysinit.author.edit files?


----------



## SilkMan (Feb 13, 2007)

I'm not Colin, but to give my slant on this, if the command or shell script is being run as a batch command - ie it runs automatically at startup, or without having a telnet client to write to - then you want to direct the output to the null device.

If the shell script is something you run from telnet and then wait for it to complete before ending the session, then you want to see the output so don't redirect it to the null device.

I'd suggest not redirecting the output from the tar command until you have it working


----------



## SilkMan (Feb 13, 2007)

PhilG, I don't see anything wrong with the script and can only think that you have a funny character in the line - does your editor allow you to see it in hex? The file you posted does not show anything untoward, although it is in DOS format (ie different line-endings) but I guess you have saved it from your editor on the PC when adding the .txt extension.

Have you tried tar --help to get the list of options? You can maybe add "z" to the list to compress the tar (like gzip) if your tar implementation allows it.

For what it's worth (and that isn't very much, I'll grant you) my script to do the backup looks like:

#!/bin/bash

# Backup my tivo files

# Copy other files into the /var/hack folder
# so they get backed up as well
mkdir /var/hack/backup`date +%y%m%d`
cd /var/hack/backup`date +%y%m%d`
cp /.profile .profile
cp /.bash_logout .bash_logout
cp /etc/rc.d/rc.sysinit rc.sysinit
cp /etc/rc.d/rc.sysinit.author rc.sysinit.author

# Tar and zip the /var/hack folder
tar -cvz /var/hack > /var/hack.`date +%y%m%d`.tar.gz 


This produces compressed tar files with timestamped names like /var/hack.070312.tar.gz

It also copies the sysinit files into a backup folder under the /var/hack along with a couple of other bits and bobs.

My apologies if this makes things even more confusing


----------



## Pete77 (Aug 1, 2006)

Ok thanks Silkman.

And to further clarify what does having a simple *&* sign at the end of a script file line achieve?


----------



## SilkMan (Feb 13, 2007)

Pete77 said:


> And to further clarify what does having a simple *&* sign at the end of a script file line achieve?


It just means run the command in the background, returning immediately to the calling shell without waiting for the task to finish. The command continues running even if it was started from the console (eg via a telnet session) and the user then logs off.


----------



## Pete77 (Aug 1, 2006)

SilkMan said:


> It just means run the command in the background, returning immediately to the calling shell without waiting for the task to finish. The command continues running even if it was started from the console (eg via a telnet session) and the user then logs off.


So which is most appropriate at the end of a Crontab line? Just* & * or *>>/dev/null 2>&1 &* Or does that depend on what the Crontab line itself does and whether or not it returns output from the program called to a log file or not?


----------



## PhilG (Jan 15, 2002)

You know, most of the things I have in my crontab, redirect to a file in /var/log/ so I can use the TW log display functions to see what's been happening

For example, my run of trackerupdate (from cron) looks like THIS on a Sunday (to restart the log)

00 06 * * 0 /tvbin/tivosh /var/hack/tracker/trackerupdate.tcl > /var/log/trackerupdate.log 2>&1

and for the rest of the week, it appends to the log

00 06 * * 1 /tvbin/tivosh /var/hack/tracker/trackerupdate.tcl >> /var/log/trackerupdate.log 2>&1
00 06 * * 2 /tvbin/tivosh /var/hack/tracker/trackerupdate.tcl >> /var/log/trackerupdate.log 2>&1
00 06 * * 3 /tvbin/tivosh /var/hack/tracker/trackerupdate.tcl >> /var/log/trackerupdate.log 2>&1
00 06 * * 4 /tvbin/tivosh /var/hack/tracker/trackerupdate.tcl >> /var/log/trackerupdate.log 2>&1
00 06 * * 5 /tvbin/tivosh /var/hack/tracker/trackerupdate.tcl >> /var/log/trackerupdate.log 2>&1
00 06 * * 6 /tvbin/tivosh /var/hack/tracker/trackerupdate.tcl >> /var/log/trackerupdate.log 2>&1


----------



## Pete77 (Aug 1, 2006)

You can simplify that Crontab to just one line using 0-6 for the days of the week.


----------



## verses (Nov 6, 2002)

Pete77 said:


> You can simplify that Crontab to just one line using 0-6 for the days of the week.


No he couldn't, but he could reduce it to 2;

00 06 * * 0 /tvbin/tivosh /var/hack/tracker/trackerupdate.tcl > /var/log/trackerupdate.log 2>&1
00 06 * * 1-6 /tvbin/tivosh /var/hack/tracker/trackerupdate.tcl >> /var/log/trackerupdate.log 2>&1

There is a subtle difference between the 2 lines;

The first has has ">" which means means 'create a file' or 'overwrite an existing file'.
The second has ">>" which means 'if there is a file append to it, if there isn't an existing file then create it'.

In this case the file that is being referred to (to be created/overwritten/appended to) is /var/log/trackerupdate.log

Ian


----------



## ColinYounger (Aug 9, 2006)

FWIW, remember to copy the backup file OFF the TiVo. Otherwise, if TiVo clears /var your backups go as well.

I don't know enough about how TiVo uses it's disk partitions to be able to tell if you can create your backup elsewhere.

I use CuteFTP which allows me to synchronise folders - in other words, I press a button and any changes on the TiVo are copied back to my machine using FTP. I then use Windows to compress the folder on my machine. Other FTP clients may do the same.

Benefit (for me) of doing this is that I can look at script files without having access to my TiVo.


----------



## AMc (Mar 22, 2002)

I have a hack.tar.gz file in the root (as viewed with FTP) from January 2006 I tried this.
Unfortunately I didn't find it until Tivo had wiped /var and I'd rebuilt it by downloading tivoweb, endpad etc. and reinstalling 
I'm not honestly sure if the file is valid as I don't have anything on the PC to validate it and I'm not juicing my Tivo hacks out of curiousity


----------



## ColinYounger (Aug 9, 2006)

It's also worth looking through this old thread which talks about recovering from a /var wipe.


----------



## Pete77 (Aug 1, 2006)

ColinYounger said:


> It's also worth looking through this old thread which talks about recovering from a /var wipe.


Thanks for pointing us to this thread Colin, although it still seemed to be somewhat confusing regarding the restore process and the MFS/Linux web access process to achieve it if you are not a techy. Are they saying that external web access may still be available on the Tivo, even though FTP will not be due to the /var wipeout? I could put a copy of the backed up tar file on my FTP file area with my ISP (the one that already contains the DailyMail image files).

This thread also rather implies that one ought to be adding the rc.sysinit directory files to the backup tar file in a somewhat different fashion to the one originally suggested, if one wants them restored correctly when the worst happens?


----------



## TCM2007 (Dec 25, 2006)

PhilG said:


> Oooohh
> 
> I assumed I could use # as a comment character
> 
> ...


I think the lack of a space between "directory" and "c.d" could be a clue.

I think you have two lines overwriting each other there, not one error message.

Sorry if this has been answered before, but does the command actually back up rc.sysinit.author?


----------



## TCM2007 (Dec 25, 2006)

Pete77 said:


> Thanks for pointing us to this thread Colin, although it still seemed to be somewhat confusing regarding the restore process and the MFS/Linux web access process to achieve it if you are not a techy. Are they saying that external web access may still be available on the Tivo, even though FTP will not be due to the /var wipeout? I could put a copy of the backed up tar file on my FTP file area with my ISP (the one that already contains the DailyMail image files).
> 
> This thread also rather implies that one ought to be adding the rc.sysinit directory files to the backup tar file in a somewhat different fashion to the one originally suggested, if one wants them restored correctly when the worst happens?


It's common to use symbolic links so that just backing up /var/hack is all that's needed, although you do need to manually restore anything outside /var/hack afterwards. I use symlinks to back up /var/mfs_ftp for instance.

As rc.sysinit.author cannot be lost in a /var wipe, I'm unclear why anyone is bothering to do it other than an occasional manual copy whne change shave been made?


----------



## TCM2007 (Dec 25, 2006)

ColinYounger said:


> FWIW, remember to copy the backup file OFF the TiVo. Otherwise, if TiVo clears /var your backups go as well.
> 
> I don't know enough about how TiVo uses it's disk partitions to be able to tell if you can create your backup elsewhere.
> 
> ...


There's usually enough room on one of the locked partitions to store the backup (gzip it first to be sure). The script would have to unlock the partiton, copy it, and re-lock it afterwards. Some folks actually reserve a small amount of space when they do a disk change and initialise it as their own EXT2 partiton, which seems OTT.


----------



## Pete77 (Aug 1, 2006)

TCM2007 said:


> As rc.sysinit.author cannot be lost in a /var wipe, I'm unclear why anyone is bothering to do it other than an occasional manual copy whne change shave been made?


What about if your hard drive goes completely belly up and you want to reinstall all your hacks and Tivoweb etc after reinstalling a basic Tivo backup. Wouldnt having a copy of rc.sysinit.author or even rc.sysinit be useful in those circumstances?


----------



## TCM2007 (Dec 25, 2006)

Read what I wrote.


----------



## PhilG (Jan 15, 2002)

TCM2007 said:


> I think the lack of a space between "directory" and "c.d" could be a clue.
> 
> I think you have two lines overwriting each other there, not one error message.
> 
> Sorry if this has been answered before, but does the command actually back up rc.sysinit.author?


Actually, now you mention it, it doesn't

And, following your comments about what disappears (and what doesn't) I don't need it to anyway!


----------



## mikerr (Jun 2, 2005)

..and why not put your "permanent/can't live without" hacks in the /usr/bin , or usr/hack instead of a /var directory anyway ? 

As I see it its just simplicity of install, so users don't have to bother with mounting/unmounting read-only or read/write.

Most well written hacks can be able run from the read-only filesystem and use /var for any runtime storage it needs.


----------



## verses (Nov 6, 2002)

mikerr said:


> ..and why not put your "permanent/can't live without" hacks in the /usr/bin , or usr/hack instead of a /var directory anyway ?


By doing that you'd run the risk that if TiVo ever got it's knickers in a twist it might not be able to fix itself by removing all it's non-standard bits.

Ian


----------



## ColinYounger (Aug 9, 2006)

TCM2007 said:


> As rc.sysinit.author cannot be lost in a /var wipe, I'm unclear why anyone is bothering to do it


In my case, simply so that I have a tarball with 'everything' required all in one place.

IOW, my backup isn't just for /var wipes.


----------



## Pete77 (Aug 1, 2006)

ColinYounger said:


> IOW, my backup isn't just for /var wipes.


Woud one also need a copy of rc.sysinit.author to get Tivoweb etc back to where it was in the event of a total hard drive failure?


----------



## ColinYounger (Aug 9, 2006)

Exactly. Using the thread I earlier posted, I have a specialised script (i.e. using a development environment I work with) to back up various bits and bobs to a laptop which in turn gets backed up to an external disk and at other intervals tape.

The idea is that in the event of a drive failure, I put new drive in, hit a few buttons and my hacks are back. I haven't tested the restore yet, as I haven't had a chance to format up a spare 200Mb drive I have squirreled off.

And to cover what I suspect you're thinking next:
No recordings backed up
No thumbs backed up
I can't release my tool as it's not in a readily usable format


----------



## PhilG (Jan 15, 2002)

Here's a thought for someone....

A script that used the info in the Dailymail config file to eMail a file from a Tivo. Then I could back up my var/hack once in a while and have the tar file eMailed to me.

Should be possible surely??


----------



## Pete77 (Aug 1, 2006)

PhilG said:


> A script that used the info in the Dailymail config file to eMail a file from a Tivo. Then I could back up my var/hack once in a while and have the tar file eMailed to me.
> 
> Should be possible surely??


The tar is 14.8MB in size.

I wouldn't want to get one of those every day. If it could be set to run just weekly or monthly that would be fine.


----------



## PhilG (Jan 15, 2002)

Pete77 said:


> The tar is 14.8MB in size.
> 
> I wouldn't want to get one of those every day. If it could be set to run just weekly or monthly that would be fine.


I did say "once in a while" - also, I haven't yet tried compressing the TAR file, so it may end up being less than 14Mb


----------



## Pete77 (Aug 1, 2006)

PhilG said:


> I did say "once in a while" - also, I haven't yet tried compressing the TAR file, so it may end up being less than 14Mb


Compressed TAR files are more inclined to become corrupted so I don't see the point really.

The obvious seemless thing would be to have some utility on Tivo that could ftp a copy of the TAR file off on to some webspace one had every day. Even then the TAR file still wouldn't have all my valuable thousands of thumbs saved and nor does the backup module do that either!   :down:


----------

