How to include multiple directories in Android auto backup rule?

Viewed 60

I have the following Android backup rule.

<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
    <!-- /data/user/0/com.xxx.yyy/databases -->
    <include domain="database" path="." />

    <!-- /data/user/0/com.xxx.yyy/shared_prefs -->
    <include domain="sharedpref" path="com.xxx.yyy_preferences.xml" />
    <include domain="sharedpref" path="com.xxx.yyy.rate.AppRater.xml" />
    <include domain="sharedpref" path="com.xxx.yyy.billing.Affiliater.xml" />
    <include domain="sharedpref" path="com.xxx.yyy.consent.Consenter.xml" />

    <!-- /storage/emulated/0/Android/data/com.xxx.yyy/files -->
    <include domain="external" path="recording/" />
    <include domain="external" path="attachment/" />
</full-backup-content>

However, I notice, by doing so, strangely only

/storage/emulated/0/Android/data/com.xxx.yyy/files/recording is backup/ restore successfully.

/storage/emulated/0/Android/data/com.xxx.yyy/files/attachment is ignored.

But, if I change the rule to

<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
    <!-- /data/user/0/com.xxx.yyy/databases -->
    <include domain="database" path="." />

    <!-- /data/user/0/com.xxx.yyy/shared_prefs -->
    <include domain="sharedpref" path="com.xxx.yyy_preferences.xml" />
    <include domain="sharedpref" path="com.xxx.yyy.rate.AppRater.xml" />
    <include domain="sharedpref" path="com.xxx.yyy.billing.Affiliater.xml" />
    <include domain="sharedpref" path="com.xxx.yyy.consent.Consenter.xml" />

    <!-- /storage/emulated/0/Android/data/com.xxx.yyy/files -->
    <include domain="external" path="attachment/" />
    <include domain="external" path="recording/" />
</full-backup-content>

/storage/emulated/0/Android/data/com.xxx.yyy/files/attachment is backup/ restore successfully.

/storage/emulated/0/Android/data/com.xxx.yyy/files/recording is ignored.

Does anyone know it is so? How can I backup both attachment and recording folders?

I am testing using guidelines at

https://developer.android.com/guide/topics/data/testingbackup

I guess we are not allow, to include multiple directories from the same domain?

1 Answers

I guess we are not allow, to include multiple directories from the same domain?

As the docs say:

To include multiple files, use multiple elements.

So you can backup multiple files by using multiple include tags with the same domain with no problem.

By the @JAAAY comment and follow the auto-backup docs:

The amount of data is limited to 25MB per user of your app

I think one of your two folders attachment or recording make the mount of backup data over 25MB, so it will be ignored until it's size is under 25MB.

enter image description here

https://developer.android.com/guide/topics/data/autobackup#xml-include-exclude

In this case, you can consider using the exlucde tag to exclude some files in two folders attachment and recording, which makes your backup data over limited in size.

Related