backup: support exclusion of user-defined directories from backups
Example: TW_BACKUP_EXCLUSIONS := /data/fonts,/data/blah,/data/geewhiz
Change-Id: I99e690eb0879281b1149e60ff430b6b3e7dd93c2
(cherry picked from commit cc683e7a3deefb96ece49b07bf88648087a7ccaf)
diff --git a/partition.cpp b/partition.cpp
index 315a159..4854fbe 100755
--- a/partition.cpp
+++ b/partition.cpp
@@ -33,6 +33,7 @@
#include <zlib.h>
#include <sstream>
#include <android-base/properties.h>
+#include <android-base/strings.h>
#include <libsnapshot/snapshot.h>
#include "cutils/properties.h"
@@ -1247,6 +1248,19 @@
backup_exclusions.add_absolute_dir("/data/extm"); //exclude this dir to prevent "error 255" on MIUI
wipe_exclusions.add_absolute_dir(Mount_Point + "/misc/vold"); // adopted storage keys
ExcludeAll(Mount_Point + "/system/storage.xml");
+
+ // board-customisable exclusions
+ #ifdef TW_BACKUP_EXCLUSIONS
+ std::vector<std::string> user_extra_exclusions = TWFunc::Split_String(TW_BACKUP_EXCLUSIONS, ",");
+ std::string s1;
+ for (const std::string& extra_x : user_extra_exclusions) {
+ s1 = android::base::Trim(extra_x);
+ if (!s1.empty()) {
+ backup_exclusions.add_absolute_dir(s1);
+ LOGINFO("Adding user-defined path '%s' to the backup exclusions\n", s1.c_str());
+ }
+ }
+ #endif
} else {
int i;
string path;