Help - Search - Members - Calendar
Full Version: [Request] foo_backup
Hydrogenaudio Forums > Hosted Forums > foobar2000 > 3rd Party Plugins - (fb2k)
jkwarras
Hi,

Just wanted to know if anyone would be interested in implementing such a plugin. Now I manually backup the files in the fb2k directory and in hte documents and settings folder (for multiple users) from time to time. It'll be very convenient if such a backup could be achieved by a plugin, so everytime you close fb2k it'll backup your important files in a specified directory. The kind of files that I backup now is the *.cfg files, history file, and the *.db (playcount and quicktag mod versions).

It'l be also a good option to backup completely in a zip/rar/7z the whole directories with the strcuture if the user ask to do so. That's what I do from time to time in order to have a complete backup of fb2k (with all plugins config).

Thanks.
WILU
QUOTE(jkwarras @ Mar 16 2005, 01:19 PM)
Hi,

Just wanted to know if anyone would be interested in implementing such a plugin. Now I manually backup the files in the fb2k directory and in hte documents and settings folder (for multiple users) from time to time. It'll be very convenient if such a backup could be achieved by a plugin, so everytime you close fb2k it'll backup your important files in a specified directory. The kind of files that I backup now is the *.cfg files, history file, and the *.db (playcount and quicktag mod versions).

It'l be also a good option to backup completely in a zip/rar/7z the whole directories with the strcuture if the user ask to do so. That's what I do from time to time in order to have a complete backup of fb2k (with all plugins config).

Thanks.
*



This may be difficult because foobar AFAIK saves config on exit, so if some changes was made during current session they will be not saved
kalmark
There's a "Save all" button on the preferences screen, maybe one could call that functionality with this component before backup...
desigrid
Great idea for a plugin. But in the event that no one takes this up, here's a script (utilising the Windows Scripting Host) that I use to backup my foobar2000 config files after foobar2000 closes. A basic level of scripting knowledge and Windows know-how is required to get this up and running.

Instructions:
1. Copy and paste the code below into a text file.
2. Modify the first 4 lines to fit your usage (see comments in script).
3. Save the script with a .js extension (e.g. foobar2000.js) into foobar2000's main directory (C:\Program Files\foobar2000\ for most).
4. Replace the regular shortcut you use to launch foobar2000 with a shortcut to this .js file.
5. Lastly, if you want to (and you most probably will), you can change the shortcut's icon to foobar2000's.

Points to note:
1. Both source path and destination path have to be already created.
2. The files and folders specified by strFiles and strFolders have to exist in the source path (obviously) but the destination path can be empty.
2. If file(s) specified by strFiles exists in the destination path, it is over-written.
3. If folder(s) specified by strFolders exists in the destination path, its entire content is deleted before the folder(s) in the source path is copied over.
4. Because of the highly configurable nature of scripts, things might go wrong, so I'd recommend that your entire foobar2000 directory be backed up first.
5. Use at your own risk. smile.gif

The example below backs up: database.foo, foobar2000.cfg, foo_playlistgen_ex.ini (in the components folder) and the entire playlists folder.

CODE

// Configurable variables -
// strSourcePath: Refers to the source path that contains the files/folders to backup.
// strDestPath: Refers to the destination path that the files/folders will backup to.
// strFiles: List of files to backup.
// strFolders: Lists of folders (and its entire contents, including sub-folders) to backup.

var strSourcePath = "C:\\Program Files\\foobar2000\\";
var strDestPath = "D:\\Application Data\\foobar2000\\";
var strFiles = new Array("database.foo", "foobar2000.cfg", "components\\foo_playlistgen_ex.ini");
var strFolders = new Array("playlists");

// Do not modify anything below this line unless you know what you're doing.

var objShell = WScript.CreateObject("WScript.Shell");
objShell.Run("foobar2000.exe", 0, true);

var objFSO = WScript.CreateObject("Scripting.FileSystemObject");

if (objFSO.FolderExists(strSourcePath) && objFSO.FolderExists(strDestPath))
{
for (var e = new Enumerator(strFiles); !e.atEnd(); e.moveNext())
{
var strFile = e.item();
var strSourceFile = strSourcePath + strFile;
var strDestFile = strDestPath + strFile;

if (objFSO.FileExists(strSourceFile))
{
var strTmp1 = "";
var strTmp2 = strFile;
do
{
strTmp1 = strTmp1 + "\\" + strTmp2.substr(0, strTmp2.indexOf("\\"))
strTmp2 = strTmp2.substr(strTmp2.indexOf("\\")+1, strTmp2.length)

if (!objFSO.FolderExists(strDestPath + strTmp1))
objFSO.CreateFolder(strDestPath + strTmp1);
} while (strTmp2.indexOf("\\") != -1);

var objFile = objFSO.GetFile(strSourceFile);
objFile.Copy(strDestFile, true);
}
else
WScript.Echo("Unable to copy " + strSourceFile + ". Source file does not exist.");
}

for (var e = new Enumerator(strFolders); !e.atEnd(); e.moveNext())
{
var strFolder = e.item();
var strSourceFolder = strSourcePath + strFolder;
var strDestFolder = strDestPath + strFolder;

if (objFSO.FolderExists(strSourceFolder))
{
if (objFSO.FolderExists(strDestFolder))
objFSO.DeleteFolder(strDestFolder);

objFSO.CopyFolder(strSourceFolder, strDestFolder);
}
else
WScript.Echo("Unable to copy " + strSourceFolder + ". Source folder does not exist.");
}
}
else
WScript.Echo("Unable to copy files. Either source path or destination path does not exist.");
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.