mirror of https://github.com/vitalif/zbackup
use '--compression lzo' instead of '--lzo', so we don't have to introduce a new argument when we add more compression methods
If we add more compression methods, we should improve it even further: We shouldn't have to edit zbackup.cc at all. IMHO, this introduces additional complexity that I wouldn't introduce before there is a good reason to do so.master
parent
767c211c5d
commit
4cf6ed1154
|
@ -149,8 +149,8 @@ want your backup process to be cpu-bound, you should consider using LZO. However
|
|||
using one core on my machine because compression is the only thing that can run in parallel.
|
||||
2. I've hacked the LZO support in a day. You shouldn't trust it. Please make sure that restore works before
|
||||
you assume that your data is safe. That may still be faster than a backup with LZMA ;-)
|
||||
3. LZMA is still the default, so make sure that you use the `--lzo` argument when you init the repo or
|
||||
whenever you do a backup.
|
||||
3. LZMA is still the default, so make sure that you use the `--compression lzo` argument when you init the
|
||||
repo or whenever you do a backup.
|
||||
|
||||
You can mix LZMA and LZO in a repository. Each bundle file has a field that says how it was compressed, so
|
||||
zbackup will use the right method to decompress it. You could use an old zbackup respository with only LZMA
|
||||
|
|
57
zbackup.cc
57
zbackup.cc
|
@ -376,32 +376,43 @@ int main( int argc, char *argv[] )
|
|||
}
|
||||
}
|
||||
else
|
||||
if ( strcmp( argv[ x ], "--lzo" ) == 0 )
|
||||
if ( strcmp( argv[ x ], "--compression" ) == 0 && x + 1 < argc )
|
||||
{
|
||||
const_sptr<Compression::CompressionMethod> lzo = Compression::CompressionMethod::findCompression( "lzo1x_1" );
|
||||
if ( !lzo )
|
||||
forcedCompressionMethod = true;
|
||||
|
||||
// next argument names the compression method
|
||||
++x;
|
||||
if ( strcmp( argv[ x ], "lzma" ) == 0 )
|
||||
{
|
||||
fprintf( stderr, "zbackup is compiled without LZO support, but the code "
|
||||
"would support it. If you install liblzo2 (including development files) "
|
||||
"and recompile zbackup, you can use LZO.\n" );
|
||||
const_sptr<Compression::CompressionMethod> lzma = Compression::CompressionMethod::findCompression( "lzma" );
|
||||
if ( !lzma )
|
||||
{
|
||||
fprintf( stderr, "zbackup is compiled without LZMA support, but the code "
|
||||
"would support it. If you install liblzma (including development files) "
|
||||
"and recompile zbackup, you can use LZMA.\n" );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
Compression::CompressionMethod::defaultCompression = lzma;
|
||||
}
|
||||
else
|
||||
if ( strcmp( argv[ x ], "lzo" ) == 0 )
|
||||
{
|
||||
const_sptr<Compression::CompressionMethod> lzo = Compression::CompressionMethod::findCompression( "lzo1x_1" );
|
||||
if ( !lzo )
|
||||
{
|
||||
fprintf( stderr, "zbackup is compiled without LZO support, but the code "
|
||||
"would support it. If you install liblzo2 (including development files) "
|
||||
"and recompile zbackup, you can use LZO.\n" );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
Compression::CompressionMethod::defaultCompression = lzo;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( stderr, "zbackup doesn't support compression method '%s'. You may need a newer version.\n",
|
||||
argv[ x ] );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
Compression::CompressionMethod::defaultCompression = lzo;
|
||||
forcedCompressionMethod = true;
|
||||
}
|
||||
else
|
||||
if ( strcmp( argv[ x ], "--lzma" ) == 0 )
|
||||
{
|
||||
const_sptr<Compression::CompressionMethod> lzma = Compression::CompressionMethod::findCompression( "lzma" );
|
||||
if ( !lzma )
|
||||
{
|
||||
fprintf( stderr, "zbackup is compiled without LZMA support, but the code "
|
||||
"would support it. If you install liblzma (including development files) "
|
||||
"and recompile zbackup, you can use LZMA.\n" );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
Compression::CompressionMethod::defaultCompression = lzma;
|
||||
forcedCompressionMethod = true;
|
||||
}
|
||||
else
|
||||
if ( strcmp( argv[ x ], "--help" ) == 0 || strcmp( argv[ x ], "-h" ) == 0 )
|
||||
|
@ -428,7 +439,7 @@ int main( int argc, char *argv[] )
|
|||
" --silent (default is verbose)\n"
|
||||
" --threads <number> (default is %zu on your system)\n"
|
||||
" --cache-size <number> MB (default is %zu)\n"
|
||||
" --lzma|--lzo\n"
|
||||
" --compression <compression> (compression is lzma or lzo, default is lzma)\n"
|
||||
" Commands:\n"
|
||||
" init <storage path> - initializes new storage;\n"
|
||||
" backup <backup file name> - performs a backup from stdin;\n"
|
||||
|
|
Loading…
Reference in New Issue