📜 ⬆️ ⬇️

Bacula: realtime filesets on Windows clients


Today we will talk about creating / restoring bacula backups under Windows.
Immediately I warn you, you will not find any revolutionary zest here, but I hope some information will be useful to some readers (so as to evaluate the flexibility of this free product).
The article is designed for those who already have little experience with bacula.

The limitation that I encountered is the inability to set a limit on the file size. But bacula supports getting a list of files through a pipe from a command that can be executed both on the client and on the server. Read more here .

So let's go.

List of requirements.
0) Russian file names must be supported!
1) do not install additional software on the client
2) customization flexibility
3) recovery flexibility
')
The source system is CentOS 5 + bacula 5.0.2 with mysql-backend + webacula.
Hint! In MySQL, the correct encoding must be set, in our case utf8.
Installation and configuration are not subject to this topic. On this topic, look for other topics on Habré. I will not describe the simplest cases either, in order not to litter the article.

To begin, let us describe a set of files for the bacula director.
It looks like this:
FileSet {
Name = XXX
..
File = "\\|c:/windows/system32/cscript.exe //NOLOGO \"C:/Program Files/Bacula/_jobs/filelist.js\""
..
}

Note that on the command line we can pass arguments to our script, incl. the maximum file size (thereby implementing point 2).

Now the script itself to create a list of files. Please note that we use CP866-> UTF-8 transcoding.
filelist.js:
 //     UTF-8 function sToUTF8(sText, srcCharset) { if (!srcCharset) srcCharset = "cp866"; //ADODB.Stream default - Unicode. KOI8-R, cp866, windows-1251 with (new ActiveXObject("ADODB.Stream")) { //http://www.w3schools.com/ado/ado_ref_stream.asp type = 2; //Binary 1, Text 2 (default) mode = 3; //Permissions have not been set 0, Read-only 1, Write-only 2, Read-write 3, //Prevent other read 4, Prevent other write 8, Prevent other open 12, Allow others all 16 charset = "utf-8"; open(); writeText(sText); position = 0; charset = srcCharset; var nPos = 3; return readText().substr(nPos); } } function ShowFolderList(folderspec) { var fso, f, fc; var p; fso = new ActiveXObject("Scripting.FileSystemObject"); f = fso.GetFolder(folderspec); re = /\\/g; //     \ -> / fc = new Enumerator(f.Files); for (; !fc.atEnd(); fc.moveNext()) { try { p = fc.item(); r = '' + p; r = r.replace(re, "/"); // replace \ to "/". if (p.Size < 2097152) // 2 MB WScript.Echo(sToUTF8(r)); } catch(e) { } } fc = new Enumerator(f.SubFolders); for (; !fc.atEnd(); fc.moveNext()) { try { ShowFolderList(fc.item()); } catch(e) { } } } ShowFolderList("D:\\Private\\Buhgalteria"); 


It is easy to see that we simply recursively run through all the folders from the source, sorting through the files and filtering under our conditions.
We now turn directly to recovery. We start on the bconsole server, we select restore and we specify the corresponding job for recovery.
At the stage of selecting files for recovery, several commands are available to us, I will describe the most useful ones:
help - hint
find - find the file you need
ls , dir - view files in the current directory (directories with subdirectories will be displayed with "+")
cd - change directory
mark file - mark the file in the current location
mark dir/ - mark a separate directory located in the current location
mark * - mark all files and directories inside the current directory. By the way, TAB also works here.
lsmark - view marked files
pwd - show current directory
estimate - calculate the size of the recovered files
done - finish mark

So The general scheme is this - we are looking for what we need through find , then go to the right directory with cd and make a mark for what we need.
Important note:
for bacula, case is important, it doesn't matter if the client is a Windows machine.

Source: https://habr.com/ru/post/134924/


All Articles