Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude an entire directory from Android 6 Auto Backup?

I'd like to configure the Android 6 Auto Backup feature to exclude all files in entire directories (both in "files" and "external"), also some specific extensions should be excluded. Will wildcards like . and *.tn-png work for the path value? I cannot explicitly define all files since these are created at run-time.

android:fullBackupContent="@xml/mybackupscheme"

where mybackupscheme would for example be this:

<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
    <exclude domain="file" path="device-links.xml"/>
    <exclude domain="file" path="*.tn-png"/>
    <exclude domain="file" path="links/*.*"/>
    <exclude domain="external" path="external-links/*.*" />
</full-backup-content>

Thanks in advance,

like image 788
Gerrit Beuze Avatar asked Jan 18 '26 04:01

Gerrit Beuze


1 Answers

The official documentation says:

path: Specifies a file or folder to include in or exclude from backup. Note that: This attribute does not support wildcard or regex syntax.

So you can't use wildcards.

But you can use exclude to exclude entire directories

<exclude> - Specifies a file or folder to exclude during backup.

If you have really complex file structure, you can implement own BackupAgent and overide onFullBackup method.

You can't easily express the set of files you want to backup with XML rules. In these rare cases, you can implement a BackupAgent that overrides onFullBackup(FullBackupDataOutput) to store what you want. To retain the system's default implementation, call the corresponding method on the superclass with super.onFullBackup().

like image 127
Artem Mostyaev Avatar answered Jan 20 '26 19:01

Artem Mostyaev