diff --git a/integration_tests/test.sh b/integration_tests/test.sh index 4cfee56..0066b2b 100755 --- a/integration_tests/test.sh +++ b/integration_tests/test.sh @@ -13,5 +13,5 @@ add_file file4 backup add_file file5 restore - +check diff --git a/integration_tests/test_functions.sh b/integration_tests/test_functions.sh index 0739411..2043356 100644 --- a/integration_tests/test_functions.sh +++ b/integration_tests/test_functions.sh @@ -26,6 +26,9 @@ TEST_REPO=$TEST_ZONE/TEST_REPO # Storage for test ( For now, only local path storage is supported by test suite) TEST_STORAGE=$TEST_ZONE/TEST_STORAGE +# Extra storage for copy operation +SECONDARY_STORAGE=$TEST_ZONE/SECONDARY_STORAGE + # Preference directory ( for testing the -pref-dir option) DUPLICACY_PREF_DIR=$TEST_ZONE/TEST_DUPLICACY_PREF_DIR @@ -46,6 +49,11 @@ function fixture() rm -rf $TEST_STORAGE mkdir -p $TEST_STORAGE + # clean SECONDARY_STORAGE + rm -rf $SECONDARY_STORAGE + mkdir -p $SECONDARY_STORAGE + + # clean TEST_DOT_DUPLICACY rm -rf $DUPLICACY_PREF_DIR mkdir -p $DUPLICACY_PREF_DIR @@ -64,6 +72,7 @@ function init_repo() { pushd ${TEST_REPO} ${DUPLICACY} init integration-tests $TEST_STORAGE + ${DUPLICACY} add -copy default secondary integration-tests $SECONDARY_STORAGE ${DUPLICACY} backup popd @@ -73,6 +82,7 @@ function init_repo_pref_dir() { pushd ${TEST_REPO} ${DUPLICACY} init -pref-dir "${DUPLICACY_PREF_DIR}" integration-tests ${TEST_STORAGE} + ${DUPLICACY} add -copy default secondary integration-tests $SECONDARY_STORAGE ${DUPLICACY} backup popd @@ -82,6 +92,7 @@ function add_file() { FILE_NAME=$1 pushd ${TEST_REPO} + dd if=/dev/urandom of=${FILE_NAME} bs=1000 count=20000 echo ${FILE_NAME} > "${FILE_NAME}" popd } @@ -91,6 +102,7 @@ function backup() { pushd ${TEST_REPO} ${DUPLICACY} backup + ${DUPLICACY} copy -from default -to secondary popd } @@ -100,4 +112,12 @@ function restore() pushd ${TEST_REPO} ${DUPLICACY} restore -r 2 -delete popd -} \ No newline at end of file +} + +function check() +{ + pushd ${TEST_REPO} + ${DUPLICACY} check -files + ${DUPLICACY} check -storage secondary -files + popd +} diff --git a/src/duplicacy_backupmanager.go b/src/duplicacy_backupmanager.go index 2fd3474..64a3cd2 100644 --- a/src/duplicacy_backupmanager.go +++ b/src/duplicacy_backupmanager.go @@ -1337,6 +1337,7 @@ func (manager *BackupManager) CopySnapshots(otherManager *BackupManager, snapsho } else { LOG_INFO("SNAPSHOT_COPY", "Copied chunk %s (%d/%d)", chunk.GetID(), chunkIndex, len(chunks)) } + otherManager.config.PutChunk(chunk) }) chunkUploader.Start() @@ -1350,7 +1351,10 @@ func (manager *BackupManager) CopySnapshots(otherManager *BackupManager, snapsho i := chunkDownloader.AddChunk(chunkHash) chunk := chunkDownloader.WaitForChunk(i) - chunkUploader.StartChunk(chunk, chunkIndex) + newChunk := otherManager.config.GetChunk() + newChunk.Reset(true) + newChunk.Write(chunk.GetBytes()) + chunkUploader.StartChunk(newChunk, chunkIndex) } chunkDownloader.Stop()