From 8c5088d5fc2f5a8bbc0a0735e5c0368800ab324f Mon Sep 17 00:00:00 2001 From: Darth9 Date: Tue, 9 Aug 2022 12:54:40 +0100 Subject: [PATCH] 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) --- Android.mk | 3 +++ partition.cpp | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/Android.mk b/Android.mk index 84dc6bec..0d2708d4 100755 --- a/Android.mk +++ b/Android.mk @@ -408,6 +408,9 @@ endif ifneq ($(TARGET_OTA_ASSERT_DEVICE),) LOCAL_CFLAGS += -DTARGET_OTA_ASSERT_DEVICE='"$(TARGET_OTA_ASSERT_DEVICE)"' endif +ifneq ($(TW_BACKUP_EXCLUSIONS),) + LOCAL_CFLAGS += -DTW_BACKUP_EXCLUSIONS='"$(TW_BACKUP_EXCLUSIONS)"' +endif LOCAL_C_INCLUDES += system/vold \ diff --git a/partition.cpp b/partition.cpp index 315a159a..4854fbee 100755 --- a/partition.cpp +++ b/partition.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include "cutils/properties.h" @@ -1247,6 +1248,19 @@ void TWPartition::Setup_Data_Media() { 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 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;