From 4a2a1267408099e0f1d2e57c322527d4979041fc Mon Sep 17 00:00:00 2001 From: Dees_Troy Date: Tue, 18 Sep 2012 09:33:47 -0400 Subject: Improve backup and restore Add in archive splitting support --- partition.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 13 deletions(-) (limited to 'partition.cpp') diff --git a/partition.cpp b/partition.cpp index 521722774..27f855e5a 100644 --- a/partition.cpp +++ b/partition.cpp @@ -683,7 +683,6 @@ bool TWPartition::Check_MD5(string restore_folder) { int index = 0; Full_Filename = restore_folder + "/" + Backup_FileName; - LOGI("Full_Filename: '%s'\n", Full_Filename.c_str()); if (!TWFunc::Path_Exists(Full_Filename)) { // This is a split archive, we presume sprintf(split_filename, "%s%03i", Full_Filename.c_str(), index); @@ -694,8 +693,8 @@ bool TWPartition::Check_MD5(string restore_folder) { } index++; sprintf(split_filename, "%s%03i", Full_Filename.c_str(), index); - LOGI("Full_Filename: '%s'\n", Full_Filename.c_str()); } + return true; } else { // Single file archive if (TWFunc::Check_MD5(Full_Filename) == 0) { @@ -708,7 +707,6 @@ bool TWPartition::Check_MD5(string restore_folder) { } bool TWPartition::Restore(string restore_folder) { - ui_print("Restoring %s...\n", Display_Name.c_str()); if (Backup_Method == FILES) return Restore_Tar(restore_folder); else if (Backup_Method == DD) @@ -995,9 +993,11 @@ bool TWPartition::Wipe_Data_Without_Wiping_Media() { } bool TWPartition::Backup_Tar(string backup_folder) { - char back_name[255]; - string Full_FileName, Tar_Args, Command; - int use_compression; + char back_name[255], split_index[5]; + string Full_FileName, Split_FileName, Tar_Args, Command; + int use_compression, index, backup_count; + struct stat st; + unsigned long long total_bsize = 0; if (!Mount(true)) return false; @@ -1013,12 +1013,33 @@ bool TWPartition::Backup_Tar(string backup_folder) { sprintf(back_name, "%s.%s.win", Backup_Name.c_str(), Current_File_System.c_str()); Backup_FileName = back_name; - Full_FileName = backup_folder + "/" + Backup_FileName; if (Backup_Size > MAX_ARCHIVE_SIZE) { // This backup needs to be split into multiple archives - LOGE("Multiple archive splitting is not implemented yet!\n"); - return false; + ui_print("Breaking backup file into multiple archives...\nGenerating file lists\n"); + sprintf(back_name, "%s", Mount_Point.c_str()); + backup_count = make_file_list(back_name); + if (backup_count < 1) { + LOGE("Error generating file list!\n"); + return false; + } + for (index=0; index