Backup

Sleep as Android provides several ways to backup and export data.

An important part of Sleep as Android is collecting statistics about your sleep. After some time, you may gather a lot of valuable data. You likely do want to keep these data even if your phone gets damaged, lost, stolen or you simply want to migrate to a new phone. You may also be interested in analysing the data outside of the application and for that you’d need to export data.

Manual export/import (CSV file)

Using MENU > Backup inv_ic_cloud_upload  you’ll see the Export data and Import data options.

By selecting the Export data option, all your sleep records will be exported to a csv file located at /sdcard/sleep-data/sleep-export.csv. You can manually download this file and backup anywhere you want. You can also use the data for your own analysis.

Clicking on the Import data option will initiate import of data from /sdcard/sleep-data/sleep-export.csv. Import will just import new records that are present in this file and they are missing in your Sleep as Android database. It will not delete or modify any of existing sleep records you already have in the application.

For documentation of the sleep-export.csv file content, see CSV file documentation.

Preventing data loss when using only local backup

After any app reinstall, make sure to Menu > Backup > Import data immediately. If you forget to do that, the app will replace your sleep-export.csv file after the next sleep record is created. The old sleep-export.csv file will be renamed to sleep-export.backup.csv.

To restore the old data:

  1. Delete the sleep-export.csv file
  2. Rename sleep-export.backup.csv to sleep-export.csv
  3. In Sleep, do Menu > Backup > Import data

Backup using Google provided backup cloud

Most Android phones support Google provided backup. This is an optional feature and it must be explicitly enabled. You can go to Settings > Backup & Restore and enable Back up my data option and Automatic restore option. When the first option is enabled, our application will backup your graphs and your alarms to a Google cloud. This is happening automatically in back-ground; you do not need to do anything.

When you install a new installation of Sleep as Android on a phone where the Automatic restore option is enabled, all data will be automatically imported. You’ll get your sleep records and your alarm settings restored.

We recommend using other methods, preferably SleepCloud, to backup your sleep records, as we have no direct control over initiation of Google backup so it may not work in all cases. This method is NOT meant to be used for synchronization of data or settings across phones.

In case you have developer tools available, you can force Google backup and restore to get reliable results. To force the backup, you can run “adb -f sleep-backup.bk backup com.urbandroid.sleep” when the old device is connected and to upload the backup to a new device run “adb restore sleep-backup.bk”.

This is the only method which backs up noise recordings metadata.

Automated backup using SleepCloud Backup

CAUTION: This method requires the Sleep Cloud Backup add-on to be installed.

This is the most convenient and reliable way to backup your sleep records. You need to have SleepCloud Backup add-on in order to benefit from this feature. The add-on automatically initiates backup when some relevant change happens (a new graph was added, an old graph was edited, etc..). The backup/restore could also be triggered manually from Graphs tap – click on the cloud icon and you’ll see Download from cloud and Upload to cloud options. The first option is used to start backup, the second to start a data restore.

Currently, we provide 3 different services where you can backup your data. You have to connect to at least one of them to benefit from the add-on. To connect, go to Settings > Cloud backup and click on the service you want to connect. You can connect more than one service if you want.

How to backup?

  • Menu > Backup > Upload to Cloud:
    • Deletes all records from SleepCloud/Drive/Dropbox, then copies all records from your phone to SleepCloud/Drive/Dropbox. If it would delete too many records, gives you a warning.
  • Menu > Backup > Download from Cloud:
    • Deletes all records from your phone, then copies all records from SleepCloud/Drive/Dropbox to your phone. If it would delete too many records, gives you a warning.

Automated backup with the SleepCloud service

This is the recommended backup service. It stores data in a special purpose cloud we designed for Sleep as Android. This backup option has several unique features not present in other options.

– You can view and modify your data online, by visiting our online cloud here.

– Unlike other services, it does a full synchronization of records including deleting/updating of existing records. This makes it the most suitable service to synchronize data among multiple devices.

– It uses optimized communication protocols so it consumes least data of all services.

SleepCloud backup also synchronizes all of your settings, so if you get a new phone, just install SleepCloud backup and all your settings will be downloaded along with the records. It works in an inobtrusive way, so if you’ve changed any of the settings on the new phone already, they won’t get overwritten.
Your active alarms will also get synchronized. The inactive ones are ignored when syncing.
In order to use SleepCloud, you need to have a valid Google account and grant us a permission to use this account when connecting to the cloud.

Automated backup with Google Drive or DropBox services

These 3rd party network storage solutions can be connected provided you have an open account there. The synchronization to/from these services works very similarly as manual backup. The plugin first creates the CSV file and then uploads this CSV file to the storage. Download from these services first downloads latest CSV file present and then imports it the same way as manual import does.

In case SleepCloud is connected, Download from cloud will ignore these 3rd party services and downloads are always done from SleepCloud.

Using WiFi only for backup

You can restrict backups to happen only when connected to WiFi. To do so, go to Device settings > Data usage and click on SleepCloud Backup. Then select option Restrict background data. The exact names of settings option may vary with android versions.

Backup of noise data

We currently do not provide any way how to automatically backup stored noise recordings. They are, however, stored on your sdcard (/sdcard/sleep-data/rec/*), so you can manually copy them wherever you want. If you use the Google-provided backup cloud, all the noise recordings metadata will be backed up.

Importing data from other apps

Joel did prepare an import script which helps to import sleep data from Sleepbot (mysleepbot.com) into Sleep as Android. Currently only sleep times, ratings and comments are supported (no activity data). Many thanks Joel! We also had to update the script later, so you’ll find it at the following address:

  • https://gist.github.com/Artaud/4524fa0d45afd144a7ddb121b1ff0d93

VeryCrazyDog has prepared another way to export data from SleepBot – without going through mysleepbot.com. Many thanks VeryCrazyDog!

  • https://github.com/VeryCrazyDog/sleepbot-to-sleep_as_android
Share