Issue Details (XML | Word | Printable)

Key: CORE-4462
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Alexander Peshkov
Reporter: Alexander Peshkov
Votes: 2
Watchers: 3
Operations

If you were logged in you would be able to see more operations.
Firebird Core

Make it possible to restore compressed .nbk files without explicitly decompressing them

Created: 17/Jun/14 10:19 AM   Updated: 14/Jan/18 04:02 PM
Component/s: NBACKUP
Affects Version/s: 3.0 Beta 1
Fix Version/s: None

File Attachments: 1. Text File nbackup-decompress-level1.patch (0.8 kB)


Sub-Tasks  All   Open   

 Description  « Hide
Ability to compress nbackup output on the fly helps to save both backup time and avoid need in disk space for intermediate uncompressed files:
nbackup -b 0 employee stdout | bzip2 >e.b0.bz2
nbackup -b 1 employee stdout | bzip2 >e.b1.bz2

Unforutnately that trick does not work when restore is needed cause a set of uncompressed files is required for utility:
nbackup -r e.fdb e.b0 e.b1

It would be great to make nbackup decompress files on the fly one by one, without wasting resources for intermediate files.

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Alexander Peshkov added a comment - 17/Jun/14 11:26 AM
Added switch -DEcompress with parameter containing command line decompressing .nbk file to stdout. Symbol @ in that command line is replaced with file name to be decompressed. If that symbol is not met in command line file name (with space before it) is appended to the end of command line. Certainly if command line contains >1 word it should be quoted according to your shell rules.

Samples of how can be restored mentioned in description backup:
nbackup -de bzcat -r e.fdb e.b0.bz2 e.b1.bz2
nbackup -de 'bzip2 -d -c' -r e.fdb e.b0.bz2 e.b1.bz2
nbackup -de 'bzip2 -d -c @' -r e.fdb e.b0.bz2 e.b1.bz2
All this commands give same result - database is successfully restored.

Sean Leyne added a comment - 17/Jun/14 03:30 PM
Wouldn't it make sense to also add a new switch to have the 'backup' step generate a compressed file directly, without the need to pipe the output?

Alexander Peshkov added a comment - 18/Jun/14 06:24 AM
I will check is it possible. If there is opened database at the time of creating backup, this causes some problems when forking.
Anyway first of all I want windows version from Vlad to clone it for backup case.

Damyan Ivanov added a comment - 14/Jan/18 04:02 PM
Hi,

While piped decompression seems to be implemented in 3.0.x series (on POSIX systems), it has a bug which leads to an error when more than one file is given to -restore (e.g. multi-level restore is performed):

$ nbackup -user sysdba -decompress 'gzip -dc' -restore test-restored.fdb test.nbk.0.gz test.nbk.1.gz
IO error seeking file: test.nbk.1.gz
-Illegal seek

The reason is that for any incremental file after the level 0 file, nbackup tries to skip a page-size block off the start of the file using seek() (nbackup.cpp line 1430), but because of the -decompress involved, the file handle is a pipe leading to the error in seek().

Here's a patch which emulates the seek with a series of read()s so that the file pointer ends up one page size from the start of the file.