diff --git a/config.cc b/config.cc index 13496c1..61edb2a 100644 --- a/config.cc +++ b/config.cc @@ -542,10 +542,15 @@ void Config::reset_storable() // TODO: Use protobuf introspection // to fill messages in loop with default values // without explicit declaration - SET_STORABLE( chunk, max_size, GET_STORABLE( chunk, max_size ) ); - SET_STORABLE( bundle, max_payload_size, GET_STORABLE( bundle, max_payload_size ) ); - SET_STORABLE( bundle, compression_method, GET_STORABLE( bundle, compression_method ) ); - SET_STORABLE( lzma, compression_level, GET_STORABLE( lzma, compression_level ) ); + Config defaultConfig; + + SET_STORABLE( chunk, max_size, defaultConfig.GET_STORABLE( chunk, max_size ) ); + SET_STORABLE( bundle, max_payload_size, defaultConfig.GET_STORABLE( + bundle, max_payload_size ) ); + SET_STORABLE( bundle, compression_method, defaultConfig.GET_STORABLE( + bundle, compression_method ) ); + SET_STORABLE( lzma, compression_level, defaultConfig.GET_STORABLE( + lzma, compression_level ) ); } void Config::show() diff --git a/zbackup.cc b/zbackup.cc index 843c352..e0b1d1a 100644 --- a/zbackup.cc +++ b/zbackup.cc @@ -156,8 +156,8 @@ invalid_option: "Usage: %s [flags] [command args]\n" " Flags: --non-encrypted|--password-file \n" -" password flag should be specified twice if import/export/passwd\n" -" command specified\n" +" password flag should be specified twice if\n" +" import/export/passwd command specified\n" " --silent (default is verbose)\n" " --help|-h show this message\n" " -O (overrides runtime configuration,\n" @@ -173,13 +173,14 @@ invalid_option: " export -\n" " performs export from source to destination storage\n" " import -\n" -" performs import from source to destination storage\n" +" performs import from source to destination storage,\n" +" for export/import storage path must be\n" +" a valid (initialized) storage\n" " gc - performs chunk garbage collection\n" " passwd - changes repo info file passphrase\n" //" info - shows repo information\n" -" config [show|edit|set] - performs configuration\n" -" manipulations (default is show)\n" -" For export/import storage path must be a valid (initialized) storage\n" +" config [show|edit|set|reset] - performs\n" +" configuration manipulations (default is show)\n" "", zbackup_version.c_str(), *argv ); return EXIT_FAILURE; } @@ -337,7 +338,7 @@ invalid_option: { if ( args.size() < 2 || args.size() > 3 ) { - fprintf( stderr, "Usage: %s %s [show|edit|set] \n", + fprintf( stderr, "Usage: %s %s [show|edit|set|reset] \n", *argv, args[ 0 ] ); return EXIT_FAILURE; } @@ -367,6 +368,15 @@ invalid_option: zbb.saveExtendedStorageInfo(); } else + if ( args.size() > 2 && strcmp( args[ fieldAction ], "reset" ) == 0 ) + { + ZBackupBase zbb( ZBackupBase::deriveStorageDirFromBackupsFile( args[ fieldStorage ], true ), + passwords[ 0 ], true ); + zbb.config.reset_storable(); + zbb.config.show(); + zbb.saveExtendedStorageInfo(); + } + else { ZBackupBase zbb( ZBackupBase::deriveStorageDirFromBackupsFile( args[ fieldStorage ], true ), passwords[ 0 ], true );