Loading...
 
[Zobrazit/Skrýt nabídky vlevo]
[Zobrazit/Skrýt nabídky vpravo]

backuppc_restore_from_cmd

Let's assume that we have a large list of directories that we want to restore. It would be very inefficient to do this manually, luckily there is an option to call the restore from the command line with a script.

First, it is vital to divide the directories to sets with a common prefix path. BackupPC restore cannot restore two directories without a common prefix path (e.g. /a/c/tmp and /b/c/tmp2) in a single batch.

Then, we have to construct a text file according to the template

%RestoreReq = (
  'fileList' => [
    [[DIRS]]
  ],
  'shareDest' => '/',
  'pathHdrDest' => '[[BASE]]/',
  'num' => '[[BACKUPNUM]]',
  'reqTime' => '[[TIME]]',
  'shareSrc' => '/',
  'pathHdrSrc' => '[[BASE]]',
  'hostDest' => '[[HOST]]',
  'hostSrc' => '[[HOST]]',
  'user' => '[[USER]]'
);

where DIRS is a comma-separated list of single-quoted directories from a single set constructed earlier. BASE is the longest common prefix path (e.g. for DIRS '/a/b/tmp/file' and '/a/b/tmp2/file2', it would be '/a/b'). BACKUPNUM is the number of the backup we want to perform the restore from (this number can be obtained from BackupPC's GUI). TIME is a unix timestamp (an integer) of the request, it is probably used to calculate the duration of the restore, fill it with some reasonable value. HOST is the name of the backuped host as configured in the BackupPC (this can be obtained from the BackupPC's GUI, e.g. 'dsa' or 'imes1.ebrana.imes'). Finally, USER is the name of the user that BackupPC uses for backup/restoration. This can be obtained from the BackupPC's GUI Edit config -> Hosts.

The easiest way to get most of the values is to read an existing finished restore. For each restore, the above described is constructed and when the restore finishes, the file is then renamed and stored in ''/data/pc/[[HOST]]/RestoreInfo.[[RESTORENUM]]. So the best way to start is to get some existing RestoreInfo? file for a given host and create a template from it.

After filling the template (by some script), the rest is just to call

/usr/share/BackupPC/bin/BackupPC_restore [[HOST IP]] [[HOST]] [[RESTOREFILE]]

where HOST IP is the IP of the restoration target, HOST is the name of the backuped host as configured in the BackupPC config, and RESTOREFILE is the name of the file prepared earlier. Note that RESTOREFILE is not a path to the file, it is just its name! The file itself must be stored in /data/pc/[[HOST]].


Created by dfabian. Last Modification: Pátek 11 of březen, 2016 10:08:18 CET by dfabian.