View Full Version : Scripts: SageTV backup scripts (dailly config, full weekly, full manual)
robogeek
08-08-2009, 03:12 PM
I thought I'd share the backup scripts I'm using to create zip archive backups that are based on the script Enormous posted here (http://forums.sagetv.com/forums/showthread.php?p=331693#post331693). These scripts create daily backups of the SageTV configuration files, full weekly SageTV directory backups, and a script to create manual backups prior to upgrades or major configuration changes. The daily config and weekly full backup scripts will also auto-delete old backups. The only additional requirement for auto-delete is that your Windows Command Line must include the forfiles command. To check this requirement, open a command prompt and type in:
forfiles
If it gives you an error, then these daily/weekly backup scripts won't auto-delete old backups for you. If the command gives you a list of files in quotes, then you should be good to go.
If you have enough space on the C: drive to hold SageTV backups then download the attached zip file and extract to the root of the C: drive. This will give you a directory structure:
C:\SageTV Backups
----C:\SageTV Backups\Config (daily auto backups)
----C:\SageTV Backups\Full (manual backups)
----C:\SageTV Backups\Full (weekly auto backups)
---sagetv-config-backup.bat
---sagetv-manual-backup.bat
---sagetv-weekly-backup.bat
---zip.exe
The zip.exe is freely redistributable and was obtained from here: http://stahlforce.com/dev/index.php?tool=zipunzip
If you don't want to put the backups on the C: drive, extract the zip to where you want the backups stored and then you'll have to modify some of the variables in the batch files to point to the correct backup location. Read on for more information.
sagetv-config-backup.bat
-----------------------------
This script will save you if something corrupts your wiz.bin database or if you make some changes to your .properties files that cause your SageTV setup to crash or misbehave. This script will backup wiz.bin, wiz.bak, sage.properties, sage.properties.autobackup, sageclient.properties, sageclient.properties.autobackup, SageTV\client\*.properties, SageTV\client\*.properties.autobackup, and the Windows irremote.ini files. And it also backs up the SageTV\Common\RemoteCodes directory. By default, it will keep 14 days of backups and delete older backups. The number of backups kept is configured with the DaysToKeep variable in the batch file. Simply set this up as a daily scheduled task in Windows to backup your configuration files automatically each day. If you have other configuration files that you want backed up, you'll have to add the appropriate commands.
sagetv-weekly-backup.bat
-----------------------------
This script is very much like the sagetv-config-backup script, with only a couple of exceptions. This script will backup your entire SageTV root (C:\Program Files\SageTV\SageTV) and SageTV Common (C:\Program Files\SageTV\Common) directories and the Windows irremote.ini file. Instead of running daily, set this script up to run as a weekly scheduled task in Windows. By default it will keep four weekly backups (4 weeks x 7 days/week = 28 days for DaysToKeep variable). Caveat regarding full backups...if you have BMT/BMI and/or the Phoenix API installed, you may want to keep your fan art and the Phoenix cache directories located outside of the SageTV root directory to keep backup sizes reasonable. You can change the fan art directory from within the Fan Art configuration in SageTV. To change the cache location, you'll have to shutdown SageTV (and SageTV Service) and locate the lines in the sage.properties file that contain cache\. There should be three of those lines. Just change the locations to someplace else and then move the cache directory from the SageTV root directory to the new location and restart SageTV. If you have other SageTV related items that are not located in the SageTV root directory or the SageTV Common directory, you'll have to add the appropriate commands to capture those items as well.
sagetv-manual-backup.bat
-----------------------------
This script is useful for making full backups before upgrading to a new SageTV release or before making significant changes to your SageTV configuration. This script is like the sagetv-weekly-backup script except you can call this script with a version number or short description (be sure spaces are replaced with _ or -) to yield backup names that can be more easily identified. So, before you upgrade from SageTV v6.6.1 to v6.6.2, you can call it like this:
sagetv-manual-backup v6.6.1
which will give you a backup named SageTV v6.6.1 Backup (mm-dd-yyyy hhmmXM).zip.
Or, before upgrading SageTV v6.6.2 with Jetty v1.5 to Jetty v1.6, you can call it like this:
sagetv-manual-backup v6.6.2_Jetty_v1.5
which will give you a backup named SageTV v6.6.2_Jetty_v1.5 Backup (mm-dd-yyyy hhmmXM).zip.
The manual backup script doesn't auto-delete any backups, so you will have to clean up these backups on your own. And again, if you have other SageTV related items that are not located in the SageTV root directory or the SageTV Common directory, you'll have to add the appropriate commands to capture those items as well.
If installing to someplace other than the root of the C: drive or if your SageTV installation is not in the default C:\Program Files\SageTV location, open each script with notepad and follow the instructions in the REM statements to configure the variables. If you have a default SageTV installation in C:\Program Files\SageTV and you keep the backups in C:\SageTV Backups then you shouldn't need to make any changes.
There are a couple of errors that you may see that are normal and are probably not an indication of any problems. Not everybody will have an irremote.ini file in their Windows directory. If you don't, the scripts will give you a 'The System cannot find the file specified' error when backing up the irremote.ini file. I believe the irremote.ini file is only used in special circumstances when you use a remote to control applications other than SageTV on your PC, so if you don't have it, don't worry about it. The other common error you'll see is when there are no backups ready to be deleted. The forfiles command will give an 'ERROR: No files found with the specified search criteria' error if no backup files are ready to be deleted. Niether of these errors are critical and they should not halt the batch file process.
These scripts copy the SageTV files to a new directory, then zips the contents of the new directory, then deletes the directory, and only the zipped backup remains. Because the scripts copy the SageTV files, you should be sure the drive with the backups has enough free space to make the copies and the zips. I mention this because of the caveat I mentioned above regarding fan art and the Phoenix API cache. My Phoenix cache was well over 1GB! I didn't feel it was necessary to backup the cache, so I moved it to the root of my fan art directory. I had already relocated the fan art when I set it up initially. I set it up in the root of one of my video import directories, and now the cache is there as well.
I'm running these scripts with no issues under Windows Home Server. They should work on XP and Vista (with UAC disabled) as well. I have never run SageTV under Vista with UAC, so the scripts probably will need to be altered to run correctly under this setup. Any questions or problems, post here and I'll try to help out.
[ADDED 8/9/09] - Backup scripts specifically for WHS.
I have attached a set of scripts that are geared toward WHS setups. Basically the same, except you should extract the zip to the Software share. This will give you a SageTV Backups directory structure in Software share. This allows you to store the backups in the storage pool and take advantage of folder duplication to add redundancy if desired. You should be sure to have enough free space on the D: drive to temporarily hold a copy of all of the files from the SageTV root and SageTV Common directories, plus a copy of the full zip file backup. To keep WHS from wasting time trying to possibly duplicate the temporary files, they will be put into a temporary area until zipped, then the zip will be copied to the final location in the Software share, and then the temporary area will be cleaned up. The temp directory doesn't have to be on the D: drive...you can modify the backupTempDir variable in the batch scripts to change the location.
[ADDED 8/9/09] - Updated both sets of scripts to allow easy configuration of additional files and directories to be backed up. If you have other SageTV/HTPC related files or directories you want to backup with the main SageTV files, you can now add them in fairly easily without having to code all of the copy commands yourself. Simply define the source pathname(s) and destination directory name(s) and set the appropriate variables to tell the script how many you have defined and you're all set. You can see more instructions and examples of how it works by opening the .bat files with a text editor. If you have problems or need help setting it up, post a message here.
[ADDED 8/11/09] - Updated both sets of scripts to fix problem when adding additional files and directories to the backup using the #filePath/#fileDestination, #dirPath/#dirDestination definitions. The extra quotes didn't seem to cause problems on my WHS machine, but may cause problems for other Windows OS versions, so I cleaned up the variables and copy commands. The #filePath/#fileDestination, #dirPath/#dirDestination variables should now be defined WITHOUT quotes if the quotes are causing errors for you. Also fixed a typo in the sagetv-config-backup script that failed to copy the sageclient.properties.autobackup file.
[EDIT] If you were running the WHS scripts, you only need to replace the sagetv-config-backup script. Fixed variable error in SageTV Backups.zip that affected manually added files.
gplasky
08-08-2009, 03:33 PM
Nice job. I'm going to test these out tonight on my WHS.
Gerry
peternm22
08-08-2009, 04:25 PM
Here's the forfiles program for those who need it: ftp://ftp.microsoft.com/reskit/y2kfix/x86/forfiles.exe
Just drop it into you Windows directory (usually C:\Windows\ ) and it should work.
Nice scripts by the way, I'll try them out when I get a chance.
robogeek
08-09-2009, 11:52 AM
Nice job. I'm going to test these out tonight on my WHS.
Gerry
Thanks. If there are any other SageTV related config files I've missed, please let me know. I've also added a new set of scripts that are basically the same, but may play a little better on WHS is you want to put the backups in the storage pool instead of on the c: or d: drive. I'm also working on adding an easy set of variables to modify to add your own files and directories to the backup without having to fully code it in yourself...just set the pathnames to the files and directories and the script will back them up.
If you want to convert to the new scripts, just move your SageTV Backups directory to the Software share, download the new attachment, and extract the three updated batch files over the existing ones. Make any changes to the batch file variables you may need and that should be it. You'll now have the backups going to the storage pool and be able to take advantage of WHS folder duplication for added security :)
robogeek
08-09-2009, 03:44 PM
Here's the forfiles program for those who need it: ftp://ftp.microsoft.com/reskit/y2kfix/x86/forfiles.exe
Just drop it into you Windows directory (usually C:\Windows\ ) and it should work.
Nice scripts by the way, I'll try them out when I get a chance.
Thanks for posting forfiles.exe link.
robogeek
08-09-2009, 03:47 PM
I have posted updated scripts that now allow you to fairly easily (if you can follow simple .batch file programming) add more files and directories to the backup:
[ADDED 8/9/09] - Updated both sets of scripts to allow easy configuration of additional files and directories to be backed up. If you have other SageTV/HTPC related files or directories you want to backup with the main SageTV files, you can now add them in fairly easily without having to code all of the copy commands yourself. Simply define the source pathname(s) and destination directory name(s) and set the appropriate variables to tell the script how many you have defined and you're all set. You can see more instructions and examples of how it works by opening the .bat files with a text editor. If you have problems or need help setting it up, post a message here.
If you installed the previous scripts, just extract the new .bat files over the old ones. If you made any edits to any of the variables in the old scripts, you'll have to re-edit the new scripts as well.
wrems
08-10-2009, 07:22 AM
Nice work! I like this very much. My approach was much less savvy and not nearly as efficient.
I just had a thought for adding redundancy for those not running raid or WHS storage pools or other schemes. I use a free program called DropBox quite a bit for synching files/file access on the internet. It is a pretty slick program. One could set up DB to hold your backup folders/batch files and have the zips that get created automatically uploaded to the internet as they get created by your batch files. That way in the event of a catastrophic event the files would be stored remotely, and accessible from any computer. This provides one more layer of protection.
All DB does is transfer whatever file(s) get placed in its folder into online storage. They start you off with 2gigs for free, which would be enough at least for the daily backups. The weekly backups, on the other hand, would probably exceed that size depending on how big the folder structure is.
The combination of your scripts and DropBox could be an eloquent way to protect these files.
Just a thought.
phareous
08-11-2009, 10:52 AM
I'm having trouble with the config backup script when I try to add additional files
First, I have to to take the quotes off of 1fileDestination because it is including the quotes in the copy line... something like
copy path1 "path2"file""
But more than that, it looks like backupTempDir is never defined...so its throwing the copied files into my C:\ root
robogeek
08-11-2009, 02:35 PM
I'm having trouble with the config backup script when I try to add additional files
First, I have to to take the quotes off of 1fileDestination because it is including the quotes in the copy line... something like
copy path1 "path2"file""
Thanks for catching that. I have fixed that and will have updated scripts posted shortly.
But more than that, it looks like backupTempDir is never defined...so its throwing the copied files into my C:\ root
Not sure why it would do that. The WHS scripts have backupTempDir set near the top of the script. By default it is set to D:\SageTV Backup Temp. The script will create the directory if it doesn't exist, but the script will also need to run with high enough privileges to create the directories. Double check the backupTempDir variable to be sure it's set to a pathname that can be created on your setup and if you changed it from the default, be sure that the pathname doesn't contain any illegal characters.
phareous
08-11-2009, 02:51 PM
This is the non-WHS scripts, and I don't see backupTempDir defined in these scripts (did a search)
robogeek
08-11-2009, 02:55 PM
I'm having trouble with the config backup script when I try to add additional files
First, I have to to take the quotes off of 1fileDestination because it is including the quotes in the copy line... something like
copy path1 "path2"file""
But more than that, it looks like backupTempDir is never defined...so its throwing the copied files into my C:\ root
Also, which OS are you running and which set of scripts are you running? I just double checked again and the extra quotes that were in the previous version of the scripts didn't cause any problems for me. I'm running Windows Home Server (WHS) and the SageTV Backup for WHS scripts. If you still run into problems, paste a copy of the top variable section of the .bat file so I can see how the variables are defined.
phareous
08-11-2009, 03:00 PM
I'm running under plain Vista (no WHS)
SET SageTVDir=C:\Program Files\SageTV
SET backupDir=C:\SageTV Backups\Config (daily auto backups)
SET windowsDir=C:\WINDOWS
SET zipexeDir=C:\SageTV Backups
SET numFiles=1
SET 1filePath="c:\ProgramData\LM Gestion\LM Remote KeyMap\*.xml"
SET 1fileDestination="LMRemoteKeymap"
SET numDirs=0
robogeek
08-11-2009, 03:03 PM
[EDIT] If you were running the WHS scripts, you only need to replace the sagetv-config-backup.bat file to correct the failed sageclient.properties.autobackup copy failure. Or find that line in the .bat file and replace the backupDir variable with backupTempDir. The other changes regarding quotes on file and directory names are more for consistency and don't affect the operation of the script.
If you were running the other set of scripts from SageTV Backups.zip, you only need to download the new scripts if you are adding files to the backup with the #filePath/#fileDestination, #dirPath/#dirDestination variables. Or open up each of the .bat files and find and replace all instances of backupTempDir with backupDir.
[EDIT]
[ADDED 8/11/09] - Updated both sets of scripts to fix problem when adding additional files and directories to the backup using the #filePath/#fileDestination, #dirPath/#dirDestination definitions. The extra quotes didn't seem to cause problems on my WHS machine, but may cause problems for other Windows OS versions, so I cleaned up the variables and copy commands. The #filePath/#fileDestination, #dirPath/#dirDestination variables should now be defined WITHOUT quotes if the quotes are causing errors for you. Also fixed a typo in the sagetv-config-backup script that failed to copy the sageclient.properties.autobackup file.
The drawback to .bat files... if you download the updated scripts, you'll have to copy any modifications you've made to the previous scripts to the new scripts. You should be able to copy and paste the variable block from the old scripts to the new ones if you've made extensive changes. The only thing you may need to change is deleting the quotes from the file/dir definitions of the additional files and directories you have added to the backup...but you probably only need to do this if the extra quotes are causing errors when copying.
robogeek
08-11-2009, 03:20 PM
I'm running under plain Vista (no WHS)
SET SageTVDir=C:\Program Files\SageTV
SET backupDir=C:\SageTV Backups\Config (daily auto backups)
SET windowsDir=C:\WINDOWS
SET zipexeDir=C:\SageTV Backups
SET numFiles=1
SET 1filePath="c:\ProgramData\LM Gestion\LM Remote KeyMap\*.xml"
SET 1fileDestination="LMRemoteKeymap"
SET numDirs=0
OK, I'm retarded :) I found the problem with the SageTV Backups script. Just change all instances of backupTempDir to backupDir and you should be good to go. The SageTV Backups for WHS script are OK, but with the standard SageTV Backups scripts I didn't change that variable after I copied/pasted.
robogeek
Awesome work, I will save this for future reference
Thanks
Scat
ChaOConnor
11-18-2009, 11:37 AM
Jason, just got WHS setup and Sage Running on it. I want to set these backups up, but everytime I run them, I get permission errors when it goes to zip the files up. I've tried running them directly from the console, but no luck. Any ideas? Thanks!
dstanley
11-18-2009, 01:58 PM
Hmmmm ... Strange happening for me on my WHS - The BAT file was compressing my Windows folder instead of the backed up folder!?
I had to 'unquiet" the zip.exe command to see what was happening.
Then I had to add a line that would chnage to my D: drive before the zip command for it to work properly:
This is the what I had to do to 'fix' it on my system:
ECHO Compressing backup: %folderName%
REM add change to D: drive
D:
REM now the proper folder gets zipped
CD "%backupTempDir%\%folderName%"
"%zipexeDir%\zip.exe" -r -9 -q -S "%backupTempDir%\%folderName%".zip *.*
CD "%zipexeDir%"
After I did this to all the scripts then it worked properly for me ...
robogeek
11-18-2009, 03:59 PM
Jason, just got WHS setup and Sage Running on it. I want to set these backups up, but everytime I run them, I get permission errors when it goes to zip the files up. I've tried running them directly from the console, but no luck. Any ideas? Thanks!
Did you grab the WHS scripts or the non-WHS script? Where did you extract them?
robogeek
11-18-2009, 04:09 PM
Hmmmm ... Strange happening for me on my WHS - The BAT file was compressing my Windows folder instead of the backed up folder!?
I had to 'unquiet" the zip.exe command to see what was happening.
Then I had to add a line that would chnage to my D: drive before the zip command for it to work properly:
This is the what I had to do to 'fix' it on my system:
ECHO Compressing backup: %folderName%
REM add change to D: drive
D:
REM now the proper folder gets zipped
CD "%backupTempDir%\%folderName%"
"%zipexeDir%\zip.exe" -r -9 -q -S "%backupTempDir%\%folderName%".zip *.*
CD "%zipexeDir%"
After I did this to all the scripts then it worked properly for me ...
In the task properties Task tab, put the full path to the directory where the scripts are located in the 'Start in' text box. If you put the scripts in the Software share as suggested, then the 'Start in' box should have:
"D:\shares\Software\SageTV Backups"
The mods you made accomplish the same thing, so there is no real need to do anything else on your part :)
ChaOConnor
11-18-2009, 06:54 PM
Did you grab the WHS scripts or the non-WHS script? Where did you extract them?
I grabbed the WHS ones and put them in the Software folder.
robogeek
11-18-2009, 07:09 PM
I grabbed the WHS ones and put them in the Software folder.
Are you running the script under a user account that has at least read access to the Program Files directory and read/write access to the Software share? If so, can you post any specific error messages so I can see what the exact error is and possibly what files or directory it's erring on? Also, be sure to execute the script from the scripts root directory. Any shortcuts or scheduled tasks should have the 'Working Directory' or 'Start In' directory set to the same directory the scripts are located in.
ChaOConnor
11-19-2009, 09:51 AM
Are you running the script under a user account that has at least read access to the Program Files directory and read/write access to the Software share? If so, can you post any specific error messages so I can see what the exact error is and possibly what files or directory it's erring on? Also, be sure to execute the script from the scripts root directory. Any shortcuts or scheduled tasks should have the 'Working Directory' or 'Start In' directory set to the same directory the scripts are located in.
Jason, i'll give this a shot tonight and let you know how it goes. Thanks!
AJ Bertelson
11-25-2009, 05:20 PM
So for the people that have sagetv on a different drive, we can just edit the backup files to change it?
robogeek
11-25-2009, 05:39 PM
So for the people that have sagetv on a different drive, we can just edit the backup files to change it?
That is correct. Just change the SageTVDir variable near the top of each script to point to your SageTV installation folder. Be sure to set it to the root installation folder and not the SageTV executable root folder. The root installation folder will be the one that has the Common and SageTV subfolders.
Hi Jason,
Thanks for sharing your work, it works great on my WHS :thumb:
Suggestion: Would it be safer for the scripts to stop the SageTV service during backup to prevent Sage from accessing/modifying files during the backup?
Rob
ChaOConnor
01-03-2010, 08:14 AM
Jason, i'll give this a shot tonight and let you know how it goes. Thanks!
Jason, attached is the error I'm getting. I'm running this from the Admin account on the WHS box. When it's done there isn't anything in the backup folder. Thanks!
robogeek
01-04-2010, 07:19 PM
Jason, attached is the error I'm getting. I'm running this from the Admin account on the WHS box. When it's done there isn't anything in the backup folder. Thanks!
I'm not sure what to tell you. If you've got a default WHS and SageTV for WHS installation, extracting the WHS version of the scripts to the D:\shares\Software folder should give you a set of working scripts.
Double check the Security tab of the Scheduled Task you set, be sure you have the Administrators group added and be sure the Administrators group has all available check boxes checked under the Allow column. Other than that, the only other thing I can suggest would be to check the permissions of "D:\SageTV Backup Temp" and "D:\shares\Software\SageTV Backups" and its subdirectories. Use Windows Explorer to check each directory to be sure the permissions on those directories are properly set for Full Access for the Adminstrators group and that none of the directories are set with the read-only attribute.
BKeadle
04-11-2010, 09:59 AM
10028Love these scripts you provided RoboGeek - nice work! :thumb:
I took your hard work and massaged it a bit so that:
- Allows you to place the script(s) on a secondary backup drive where ever you want the backups to go and run without modifying the scripts
- Removed the need to set some other unnecessary variables. zip.exe and forfiles.exe just need to be in the same directory as the backup script.
- For the manual backup, the version of SageTV is extracted from the registry, so no need to pass the version parameter when doing a MANUAL backup.*
- combined the 3 separate scripts into one script so you only need to set variables in (or manage) one file. Simply pass a parameter to do a CONFIG WEEKLY or MANUAL backup, e.g.:
SAGETV-BACKUP CONFIG
However, I've also included the 3 modified script in the event one still wants them broken out into 3 separate files.
- append to a SAGETV Backups.log file when backups are executed
- Because I want to take a "backup of the backup" (yeah, I know...I like a second copy of the last backup to a removeable CF card), I've allowed for a "post processing" script. If a POSTBACKUP.CMD script in the same directory, it will be called (with the same passed backup parameter) after a successful backup. I've included my POSTBACKUP.CMD in the attached zip that doesn't do anything - my commands are REM'd out.
A representative directory listing for the backup target looks like this:
V:\SAGETV BACKUPS\
sagetv-backup.cmd
sagetv-config-backup.cmd
sagetv-manual-backup.cmd
sagetv-weekly-backup.cmd
PostBackup.cmd
SageTV Config Backup (04-11-2010 1029AM).zip
SageTV Full Backup (04-11-2010 0905AM).zip
SageTV_6.6.2 Backup (04-11-2010 0855AM).zip
SageTV Backups.log
zip.exe
forfiles.exe
When modifying the script to suit your own environment, the same instructions apply. The variables to be set I've made left-justified to make it easier to identify the settings to be reviewed. Simply review the SET variables that exist below the :BEGIN label. All other lines that are indented need not be modified.
To distinguish my version from the original versions by RoboGeek, my scripts use the .CMD extension instead of .BAT
:goodjob:
*I'm not sure if the registry reference is the same for different versions of SageTV. I'd appreciate it if someone could confirm that the following registry key is the same for a non-6.6.2 version of SageTV:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\F5CF942D133B1C747A31CE8714DA8D6F\InstallProperties\[DisplayVersion]
Greg2dot0
06-09-2010, 12:41 PM
I took a different path and decided on using "pushd" and "popd" which makes it work no matter what drive they are on.
phareous
07-16-2010, 09:23 PM
I tried the ones from bkeadle. My weekly backup fails:
Setting temp folder name = SageTV Full Backup (07-16-2010 1100PM)
Backing up SageTV Common directory...
Backing up SageTV directory...
Backing up Irremote.ini file...
Backing up manually defined files...
...Backing up c:\Program Files\SageTV\SageTV\*.frq
...Backing up c:\ProgramData\LM Gestion\LM Remote KeyMap\*.xml
Cleaning up old backups...
Compressing backup: SageTV Full Backup (07-16-2010 1100PM)
zip I/O error: Invalid argument
zip error: Input file read failure (was zipping SageTV/cache/imagefactory/v7phoe
nix/099c8465247ee34fb151b50b6990e498.png)
Keeping compressed backup...
Deleting backup directory: SageTV Full Backup (07-16-2010 1100PM)
Failed to create C:\SageTV Backups\\SageTV Full Backup (07-16-2010 1100PM).zip
Out of disk space?
Volume in drive C has no label.
Volume Serial Number is B0C9-DD1F
Directory of C:\SageTV Backups
07/16/2010 10:20 PM 22,950,383 SageTV Config Backup (07-16-2010 1020PM).
zip
1 File(s) 22,950,383 bytes
0 Dir(s) 402,830,938,112 bytes free
Press any key to continue . . .
phareous
07-16-2010, 09:47 PM
I noticed the zip.exe was quite old (2.32) so I upgraded to 3.0 and reran, and that seemed to fix it. Took me a while to find the new infozip...this worked:
ftp://ftp.info-zip.org/pub/infozip/win32/zip300xn.zip
there is also a 64 bit version:
ftp://ftp.info-zip.org/pub/infozip/win32/zip300xn-x64.zip
btrcp2000
09-04-2010, 02:22 PM
Thanks for putting these together, great tools!
Manual backup is backing up my entire windows directory, giving me a 1.5gb zip file. I know there's a simple fix to the batch file, but I can't put my finger on it
here's the part of the batch file that lists the directories it's looking at, which I believe I left untouched from the original. There is no irrremote file in my windows directory, not even sure what that is. Can I just delete that line, is that the problem?
REM SageTVDir = your SageTV install directory
SET SageTVDir=C:\Program Files\SageTV
REM backupDir = where you want the backup .zip files for weekly backups stored
SET backupDir=D:\shares\Software\SageTV Backups\Full (manual backups)
REM backupTempDir = where you want temp files to be stored before being zipped
SET backupTempDir=D:\SageTV Backup Temp
REM windowsDir = where the irremote.ini file is stored (not everybody has or needs this)
SET windowsDir=C:\WINDOWS
REM zipexeDir = where the zip.exe zipping program is located
SET zipexeDir=D:\shares\Software\SageTV Backups
robogeek
09-04-2010, 03:34 PM
I'm not sure what would cause it to copy the whole Windows directory. Here are the lines further down in the batch file that process the irremote.ini file:
ECHO Backing up Irremote.ini file...
COPY "%windowsDir%\Irremote.ini" "%backupTempDir%\%folderName%"
You can remove those two lines or just add REM in front of them to prevent them from being processed like this:
REM ECHO Backing up Irremote.ini file...
REM COPY "%windowsDir%\Irremote.ini" "%backupTempDir%\%folderName%"
robogeek
09-04-2010, 04:49 PM
READ THIS IF YOU ARE USING THESE SCRIPTS WITH SAGETV V7!
While it's fresh in my mind, the sagetv-config-backup script isn't fully compatible with SageTV v7 and may cause problems with the plugins installed using the plugin manager if you restore one of these config backups. The plugin manager uses an additional properties file (filetracker.properties and filetracker.properties.autobackup) and some plugins store additional properties and other information in their own folders. The plugin manager stores info in the SageTV main properties file as well as the filetracker properties file. If these properties files get out of sync, it may cause issues with plugins failing, failing to uninstall, or failing to install. I'm not sure what kind of sanity checks the plugin manager has to prevent these possible situations, so please be careful restoring configuration backups.
The weekly and manual backups should catch everything, but the additional files and folders would have to be added to the sagetv-config-backup script to ensure things don't go bad when restoring configuration backups. I'll try to get these incorporated along with some of the great additions others have added to the original scripts.
btrcp2000
09-05-2010, 07:29 AM
REM'ed out those two lines, no effect. I watched it all the way through this time, and the only thing that looked out of whack were a bunch of "zip permission denied" messages. In the end, it still made a backup of the entire windows directory. could this have anything to do with admin rights or something? (yes I am logged into whs as admin)
I cannot for the life of me figure out why it won't focus on the sage directory. If there's no answer, I guess I need to find a different backup solution.
robogeek
09-05-2010, 09:06 AM
REM'ed out those two lines, no effect. I watched it all the way through this time, and the only thing that looked out of whack were a bunch of "zip permission denied" messages. In the end, it still made a backup of the entire windows directory. could this have anything to do with admin rights or something? (yes I am logged into whs as admin)
I cannot for the life of me figure out why it won't focus on the sage directory. If there's no answer, I guess I need to find a different backup solution.
How are you starting the .bat? If you open a command, prompt browse to the script directory, and start it manually, does it still try to zip up the Windows directory? If it works from the command line, then the Windows Task or Shortcut you have setup probably doesn't have the "Start In" property set to the location of the script directory. A Windows Task probably defaults to the C:\Windows location and would cause the script to fail to change to the backupTempDir if it is on another drive which would result in the script trying to zip up the Windows directory. If you run the script as a Windows Task, open the task from the Windows Task Scheduler in the Windows Control Panel. Check the Start In property and be sure it is set to the directory where the script is located, and be sure the directory name has quotes around it (I think the quotes are only required if the directory name has spaces in it).
If that isn't the problem, post the .bat file here and let me know how you are starting the .bat file and I'll test it out to see if I can duplicate your results.
BKeadle
09-05-2010, 09:24 AM
Also, are you using the .BAT, or my .CMD version? If we could see the script you're running, it'd help.
You could also add this to the .BAT file just after the @echo off line:
cd /d %~dp0
This will ensure that the working directory is changed to the same directory where the .BAT file exists. (the .CMD file already has this) This has the same effect as properly setting the Start In value of the shortcut.
btrcp2000
09-05-2010, 10:26 AM
gonna feel real stupid if this is the problem but i've just been double clicking the bat file. i never set up tasks because iwas just doing it manually to see how things worked. is that not the way the manual backup is intended to be kicked off?
i did just d/l frsh versions of the whs scripts, left them untouched and got the same result. i will upload later when i have a chance, out and about for the day.
thx for the efforts
robogeek
09-05-2010, 03:41 PM
gonna feel real stupid if this is the problem but i've just been double clicking the bat file. i never set up tasks because iwas just doing it manually to see how things worked. is that not the way the manual backup is intended to be kicked off?
i did just d/l frsh versions of the whs scripts, left them untouched and got the same result. i will upload later when i have a chance, out and about for the day.
thx for the efforts
Double clicking the .bat file should work. If it's a shortcut to the .bat file, then it needs the Start In or Working Directory set to the directory where the script is located, or add the line BKeadle suggested to the .bat file.
If you downloaded the WHS version of the scripts, did you unzip the file to the Software share (d:\shares\Software)? The WHS scripts expect to be extracted (keeping the zip folder sturcture intact) to the Software share and should work without requiring any mods to the scripts. Double check the user defined directories in the beginning of the script and be sure they are correct and that they actually exist on the hard drive. The only difference between the WHS and standard Windows version of the scripts is the fact that the WHS scripts were pre-moded to work from the Software share so WHS users wouldn't have to touch anything in the .bat files so they should work if they were installed to the Software share and are being run under an account with Administrator privileges. Unless you've customized WHS in some weird way or did something weird with permissions on the Software share, I'm stumped.
btrcp2000
09-05-2010, 05:27 PM
I'm guessing it's something to do with syntax and quotation marks. I just made an unscheduled task in "scheduled tasks" without changing the bat, and it worked fine. good enough for me, thanks!
Peter_h
09-30-2010, 06:07 AM
Jason, attached is the error I'm getting. I'm running this from the Admin account on the WHS box. When it's done there isn't anything in the backup folder. Thanks!
Did you ever figure this one out? I'm running the script on WHS and I'm getting the same exact error messages.
HuMan321
10-31-2010, 11:38 AM
READ THIS IF YOU ARE USING THESE SCRIPTS WITH SAGETV V7!
While it's fresh in my mind, the sagetv-config-backup script isn't fully compatible with SageTV v7 and may cause problems with the plugins installed using the plugin manager if you restore one of these config backups. The plugin manager uses an additional properties file (filetracker.properties and filetracker.properties.autobackup) and some plugins store additional properties and other information in their own folders. The plugin manager stores info in the SageTV main properties file as well as the filetracker properties file. If these properties files get out of sync, it may cause issues with plugins failing, failing to uninstall, or failing to install. I'm not sure what kind of sanity checks the plugin manager has to prevent these possible situations, so please be careful restoring configuration backups.
The weekly and manual backups should catch everything, but the additional files and folders would have to be added to the sagetv-config-backup script to ensure things don't go bad when restoring configuration backups. I'll try to get these incorporated along with some of the great additions others have added to the original scripts.
Was this issue with V7 plug-ins ever resolved?
Thanks,
robogeek
10-31-2010, 12:35 PM
Was this issue with V7 plug-ins ever resolved?
Thanks,
No, not yet. There should be no problems using the weekly or manual full backup scripts with SageTV V7, but extreme caution should be taken with daily config backups. For daily config backups, the main problem is restoring the sage.properties file that contains some critical plugin information. If the plugin data in the sage.properties file doesn't match up with what is in the filetracker.properties file and with the actual contents of the JARs, PluginInstallers, and various other plugin related folders, you'll likely end up with plugins out of sync and in an inconsistent state.
I'm considering just removing the daily config backup script and making the weekly full backup the new daily backup script. Seems a bit overkill, but I think it would be the safest way to go.
HuMan321
11-01-2010, 03:22 PM
Thanks for the reply.
Did you need to install an add-in to your WHS for a scheduler such as this?
New Add-in: WHS Trigger
I would like to move my cache files to the D: shares as well. The folder name would be cache and it would be a subfolder of Fanart which is on the D share. I get confused on the syntax (/\) Could you help?
The location would be D:/shares/fanart/cache or D:\shares\fanart\cache to change the location in the properties file?n Any spaces needed in the property file?
Thanks,
robogeek
11-01-2010, 07:44 PM
Thanks for the reply.
Did you need to install an add-in to your WHS for a scheduler such as this?
New Add-in: WHS Trigger
I would like to move my cache files to the D: shares as well. The folder name would be cache and it would be a subfolder of Fanart which is on the D share. I get confused on the syntax (/\) Could you help?
The location would be D:/shares/fanart/cache or D:\shares\fanart\cache to change the location in the properties file?n Any spaces needed in the property file?
Thanks,
For the scheduler, I just used the builtin Windows Task Scheduler which is available in the Control Panel. You'll either need to login to the WHS machine with Remote Desktop, login directly at the WHS machine, or use an Add-in that allows you to access the Control Panel from the WHS Console. In the Task Scheduler settings, just remember to set the 'Start in' setting to the base directory where the scripts are located.
For the cache directory change in the sage properties file, I use backslashes. And the colon and backslashes need to be escaped with backslashes. So you would have:
D\:\\shares\\fanart\\cache
But I think you can also use forward slashes which don't need to be escaped, but the colon still needs to be escaped with a backslash like this:
D\:/shares/fanart/cache
There are a few different bmt/phoenix/fanart cache properties. Be sure to scan the sage properties file for the word cache and any properties that start with bmt or phoenix you might want to move off of the C: partition to ensure none of the bmt/phoenix cache files fill up what little space is left on that small 20GB C: partition.
phareous
11-05-2010, 07:34 PM
Imagine my surprise today when I needed to actually use the weekly backup and found that it backed up absolutely none of the subdirectories of the SageTV folder
These xcopy flags seem to fix the issue:
/c /h /e /y /q
c - continue if errors happened
h - copy hidden and system files
e - copy all subdirectories
y - say yes if there is an overwrite prompt
q - quiet
phareous
11-05-2010, 07:36 PM
Also just to clarify, I believe locked files were causing the issue, thus the /C flag fixes that (skips the files)
In my case it appears to be a directory called activemq-data/ortus
phareous
11-05-2010, 08:23 PM
I also found it helpful to exclude a few directories, which saved over 2 GB in my case. I don't know how to exclude them with xcopy so I just remove them before the zip is created:
ECHO Compressing backup: %folderName%
CD /D "%backupDirTemp%\%folderName%"
RD /s /Q "%backupDirTemp%\%folderName%\SageTV\cache"
RD /s /Q "%backupDirTemp%\%folderName%\SageTV\STVs\Ortus\Trailers"
"%~DP0\zip.exe" -r -9 -q -S "%~DP0\%folderName%".zip *.*
ptzink
01-23-2012, 02:26 PM
Digging up an old thread... I am going to start using these scripts, but is there the opportunity (read: likelihood) that my wiz.bin backup will be corrupt each time since the sagetv service is always running when the backup is made? Or does something in the script accommodate for this situation? If not, how are other people running these scripts shutting down the service prior to backup to ensure a good wiz.bin file. Thanks for the help.
Slugger
01-23-2012, 06:08 PM
Prior to each EPG update the core creates wiz.bak - backup that file instead of wiz.bin. If you schedule the backup to happen shortly after an EPG update then the wiz.bak is pretty close to a live backup.
pjwerdna
01-24-2012, 06:24 AM
Prior to each EPG update the core creates wiz.bak - backup that file instead of wiz.bin. If you schedule the backup to happen shortly after an EPG update then the wiz.bak is pretty close to a live backup.
This is correct. But doesnt guarantee that either wiz file is not corrupt.
Ive had four times when SageTV stopped updating the wiz files correctly and the only time I found out was when I restarted the SageTV service.
As far as I can tell it creates the wiz.bak and then tries to update the wiz.bin. If this update fails, then the next time it does this update process it overwrites the usable wiz.bak with the now corrupted wiz.bin.
I currently backup all configuration files every night and keep every backup (theyre only a few MB) The last corruption caused me to go back nearly two months until I could find a wiz file that wasnt instantly marked as corrupt.
One thing I have found is that after the EPG update the wiz.bak is usually bigger than the wiz.bin, unless the wiz.bin is corrupt in which case wiz.bin seems to get appended to and so be larger than the backup.
vBulletin® v3.7.6, Copyright ©2000-2013, Jelsoft Enterprises Ltd.