Async-storage: Document backup behaviour

Created on 13 Nov 2019  路  10Comments  路  Source: react-native-async-storage/async-storage

Motivation

Hi, it would be nice if you could update the documentation to include information about whether AsyncStorage data is stored and restored in iCloud and android backups, and what configuration steps might be necessary for this (i.e. android manifest android:fullBackupContent etc.)

Description

see Motivation

documentation

Most helpful comment

Android:

IOS:

  • https://developer.android.com/guide/topics/data/autobackup.html
  • generally Library/ and Documents/ are backed up unless a special file attribute is set
  • restoring AsyncStorage settings works out of the box for me for iOS 13.3
  • To test backup and restore without actually restoring the phone you can offload an app using settings / storage and click "Offload App"

All 10 comments

Good idea. On iOS, AsyncStorage saves the data to the file, that's accessible for user to look into. There's a feature request that allows you to change the default save location. We'd have to keep this in mind if we were to write docs about it.

I would really appreciate that! Is there any information already somewhere how to properly backup and restore AsyncStorage data?

@zwenza

Here are Android docs regarding auto backup (Android 23+). Haven't tested it against AsyncStorage though.

Android:

IOS:

  • https://developer.android.com/guide/topics/data/autobackup.html
  • generally Library/ and Documents/ are backed up unless a special file attribute is set
  • restoring AsyncStorage settings works out of the box for me for iOS 13.3
  • To test backup and restore without actually restoring the phone you can offload an app using settings / storage and click "Offload App"

@mo22
Is there any way to opt-out of auto-backup feature in iOS?. In android changing android:allowBackup="false" does it. Anything similar in iOS? I have a privacy concern and need to clear the app data on uninstall.

I don't think there's an built-in way.

You could use https://github.com/mo22/react-native-mo-fs and manually set the backup attribute for the storage directory.

Fs.ios.Module.setResourceValues('file:///path/to/file', {
  'NSURLIsExcludedFromBackupKey': true,
});

@nishantpillai5
Related issue. I'll come up with solution in upcoming days

We'll in the latest version one by default opts out of backups. However I'm wondering how everyone else managed to get app data backed up in the first place?

I've tried with 0.13 and pre 0.13 releases - our app data never gets saved in the cloud. Do I need to enable some capabilities?

We use redux and redux-persist and redux-persist stores the data using async storage. I've downloaded the appData from the phone and I can see that the async files are stored inside of the Docs folder. So I don't understand how everyone else managed to back up the data in the cloud and I didn't :)

We'll in the latest version one by default opts out of backups. However I'm wondering how everyone else managed to get app data backed up in the first place?

Devs were raising concern that might be the happening in some cases for their users. I could not repro this myself, but went ahead and added a this as a feature toggle, off by default.

Here is the documentation about it
https://react-native-async-storage.github.io/async-storage/docs/advanced/backup

@Krizzu - I saw those docs. I was actually asking - how do you force AsyncStorage to store the data in iCloud? We've set the RCTAsyncStorageExcludeFromBackup to false, but our data is never uploaded to icloud. How does one configure an app to upload the data? Is there something in XCode that needs to be configured? I added iCloud as capability in it, but our data never left the device...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Krizzu picture Krizzu  路  36Comments

sumanthyedoti picture sumanthyedoti  路  25Comments

srivatsav picture srivatsav  路  26Comments

mxmzb picture mxmzb  路  19Comments

dominiczaq picture dominiczaq  路  22Comments