mirror of https://github.com/vitalif/zbackup
parent
e76c0db562
commit
3ff24945a2
|
@ -3,17 +3,6 @@
|
|||
|
||||
#include "backup_collector.hh"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "bundle.hh"
|
||||
#include "chunk_index.hh"
|
||||
#include "backup_restorer.hh"
|
||||
#include "backup_file.hh"
|
||||
#include "backup_exchanger.hh"
|
||||
|
||||
#include "debug.hh"
|
||||
|
||||
using std::string;
|
||||
|
||||
void BundleCollector::startIndex( string const & indexFn )
|
||||
|
|
|
@ -4,18 +4,11 @@
|
|||
#ifndef BACKUP_COLLECTOR_HH_INCLUDED
|
||||
#define BACKUP_COLLECTOR_HH_INCLUDED
|
||||
|
||||
#include "zbackup_base.hh"
|
||||
#include "chunk_storage.hh"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "bundle.hh"
|
||||
#include "chunk_index.hh"
|
||||
#include "backup_restorer.hh"
|
||||
#include "backup_file.hh"
|
||||
#include "backup_exchanger.hh"
|
||||
|
||||
#include "debug.hh"
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ using std::pair;
|
|||
enum {
|
||||
backups,
|
||||
bundles,
|
||||
index,
|
||||
indexes,
|
||||
Flags
|
||||
};
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ void Config::prefillKeywords()
|
|||
"Valid values:\n"
|
||||
"backups - exchange backup instructions (files in backups/ directory)\n"
|
||||
"bundles - exchange bundles with data (files in bunles/ directory)\n"
|
||||
"index - exchange indicies of chunks (files in index/ directory)\n"
|
||||
"indexes - exchange indexes of chunks (files in index/ directory)\n"
|
||||
"No default value, you should specify it explicitly"
|
||||
},
|
||||
|
||||
|
@ -439,12 +439,13 @@ bool Config::parseOrValidate( const string & option, const OptionType type,
|
|||
if ( strcmp( optionValue, "bundles" ) == 0 )
|
||||
runtime.exchange.set( BackupExchanger::bundles );
|
||||
else
|
||||
if ( strcmp( optionValue, "index" ) == 0 )
|
||||
runtime.exchange.set( BackupExchanger::index );
|
||||
if ( strcmp( optionValue, "indexes" ) == 0 ||
|
||||
strcmp( optionValue, "index" ) == 0 )
|
||||
runtime.exchange.set( BackupExchanger::indexes );
|
||||
else
|
||||
{
|
||||
fprintf( stderr, "Invalid exchange value specified: %s\n"
|
||||
"Must be one of the following: backups, bundles, index.\n",
|
||||
"Must be one of the following: backups, bundles, indexes.\n",
|
||||
optionValue );
|
||||
return false;
|
||||
}
|
||||
|
|
41
zbackup.cc
41
zbackup.cc
|
@ -172,7 +172,8 @@ invalid_option:
|
|||
" performs import from source to destination storage,\n"
|
||||
" for export/import storage path must be\n"
|
||||
" a valid (initialized) storage\n"
|
||||
" gc <storage path> - performs chunk garbage collection\n"
|
||||
" gc [chunks|indexes] <storage path> - performs garbage\n"
|
||||
" collection (default is chunks)\n"
|
||||
" passwd <storage path> - changes repo info file passphrase\n"
|
||||
//" info <storage path> - shows repo information\n"
|
||||
" config [show|edit|set|reset] <storage path> - performs\n"
|
||||
|
@ -278,15 +279,43 @@ invalid_option:
|
|||
else
|
||||
if ( strcmp( args[ 0 ], "gc" ) == 0 )
|
||||
{
|
||||
// Perform the restore
|
||||
if ( args.size() != 2 )
|
||||
// Perform the garbage collection
|
||||
if ( args.size() < 2 || args.size() > 3 )
|
||||
{
|
||||
fprintf( stderr, "Usage: %s %s <storage path>\n",
|
||||
fprintf( stderr, "Usage: %s %s [chunks|indexes] <storage path>\n",
|
||||
*argv, args[ 0 ] );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
ZCollector zc( args[ 1 ], passwords[ 0 ], config );
|
||||
zc.gc();
|
||||
|
||||
int fieldStorage = 1;
|
||||
int fieldAction = 2;
|
||||
|
||||
if ( args.size() == 3 )
|
||||
{
|
||||
fieldStorage = 2;
|
||||
fieldAction = 1;
|
||||
}
|
||||
|
||||
if ( args.size() > 2 && strcmp( args[ fieldAction ], "chunks" ) == 0 )
|
||||
{
|
||||
ZCollector zc( ZBackupBase::deriveStorageDirFromBackupsFile( args[ fieldStorage ], true ),
|
||||
passwords[ 0 ], config );
|
||||
zc.gcChunks();
|
||||
}
|
||||
else
|
||||
if ( args.size() > 2 && strcmp( args[ fieldAction ], "indexes" ) == 0 )
|
||||
{
|
||||
ZCollector zc( ZBackupBase::deriveStorageDirFromBackupsFile( args[ fieldStorage ], true ),
|
||||
passwords[ 0 ], config );
|
||||
fprintf( stderr, "NOT IMPLEMENTED YET!\n" );
|
||||
zc.gcIndexes();
|
||||
}
|
||||
else
|
||||
{
|
||||
ZCollector zc( ZBackupBase::deriveStorageDirFromBackupsFile( args[ fieldStorage ], true ),
|
||||
passwords[ 0 ], config );
|
||||
zc.gcChunks();
|
||||
}
|
||||
}
|
||||
else
|
||||
if ( strcmp( args[ 0 ], "passwd" ) == 0 )
|
||||
|
|
14
zutils.cc
14
zutils.cc
|
@ -207,13 +207,13 @@ void ZExchange::exchange()
|
|||
verbosePrintf( "Bundle exchange completed.\n" );
|
||||
}
|
||||
|
||||
if ( config.runtime.exchange.test( BackupExchanger::index ) )
|
||||
if ( config.runtime.exchange.test( BackupExchanger::indexes ) )
|
||||
{
|
||||
verbosePrintf( "Searching for indicies...\n" );
|
||||
vector< string > indicies = BackupExchanger::findOrRebuild(
|
||||
verbosePrintf( "Searching for indexes...\n" );
|
||||
vector< string > indexes = BackupExchanger::findOrRebuild(
|
||||
srcZBackupBase.getIndexPath(), dstZBackupBase.getIndexPath() );
|
||||
|
||||
for ( std::vector< string >::iterator it = indicies.begin(); it != indicies.end(); ++it )
|
||||
for ( std::vector< string >::iterator it = indexes.begin(); it != indexes.end(); ++it )
|
||||
{
|
||||
verbosePrintf( "Processing index file %s... ", it->c_str() );
|
||||
string outputFileName ( Dir::addPath( dstZBackupBase.getIndexPath(), *it ) );
|
||||
|
@ -307,7 +307,7 @@ ZCollector::ZCollector( string const & storageDir, string const & password,
|
|||
{
|
||||
}
|
||||
|
||||
void ZCollector::gc()
|
||||
void ZCollector::gcChunks()
|
||||
{
|
||||
ChunkIndex chunkReindex( encryptionkey, tmpMgr, getIndexPath(), true );
|
||||
|
||||
|
@ -366,3 +366,7 @@ void ZCollector::gc()
|
|||
|
||||
verbosePrintf( "Garbage collection complete\n" );
|
||||
}
|
||||
|
||||
void ZCollector::gcIndexes()
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue