Secure, Drop-in Google Drive Backup for Android Room Databases
Backpack is a production-ready Android library that encrypts, exports, and uploads your Room database to a private Google Drive App Folder. It manages SQLite WAL/SHM complexity, handles Google Identity Services authentication, and offers a plug-and-play UI.
-
AES-256 Encryption Encrypts all database files before upload.
-
Google Drive App Folder Stores backups in an isolated, hidden location users can't tamper with.
-
Coroutines & Flow Fully asynchronous, modern Kotlin API.
-
Room-Aware Backup Engine Gracefully handles WAL, SHM, checkpointing, and safe DB closure.
-
Built-in UI Includes a
BackupViewfor instant onboarding and authentication handling.
Backpack is used in production by:
- AutoSend - Get it on Google Play
Add to settings.gradle.kts:
dependencyResolutionManagement {
repositories {
...
maven { url = uri("https://jitpack.io") }
}
}dependencies {
implementation("com.github.vedraj360:Backpack:1.0.3")
}class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
val database = MyDatabase.getInstance(this)
val config = BackupConfig(
database = database,
folderName = "My App Backups",
encryptionEnabled = true,
backupFileName = "user_data",
maxBackupFiles = 5
)
Backpack.initialize(this, config)
}
}<com.vdx.backpack.ui.custom.BackupView
android:id="@+id/backupView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:signInTitle="Cloud Sync"
app:signInDescription="Sign in to keep your data safe."
app:showAutoBackupToggle="true" />val isAuth = Backpack.driveProvider.isAuthenticated()
val intent = Backpack.driveProvider.getSignInIntent(activity)
Backpack.driveProvider.handleSignInResult(activity, dataIntent)
.onSuccess { email -> Log.d("Auth", "Signed in: $email") }
.onFailure { e -> Log.e("Auth", "Failed", e) }
Backpack.driveProvider.signOut(activity)lifecycleScope.launch {
Backpack.manager.backup(context).collect { result ->
when (result) {
is BackupResult.InProgress -> showProgress(result.progress)
is BackupResult.Success -> showSuccess("Saved!")
is BackupResult.Failure -> showError(result.error)
}
}
}val result = Backpack.manager.listAvailableBackups()
val latestFile = result.getOrNull()?.firstOrNull()
latestFile?.let { file ->
Backpack.manager.restore(context, file.fileId).collect { result ->
if (result is BackupResult.Success) {
AppRestartHelper.triggerRestart(context)
}
}
}Backpack requires a Google Cloud project with an OAuth Client ID for Drive access.
Setup guide: Google Cloud Setup Guide
- Google Sign-In Developer Error (Status Code 10):
This usually indicates a mismatch between the SHA-1 fingerprint of the signing certificate used to build your APK/Bundle and the SHA-1 registered in the Google Cloud Console.
- Make sure you have added both your Debug SHA-1 (generated locally) and your Release SHA-1 (from Google Play Console if using Play App Signing, or your release keystore) to your Google Cloud OAuth Client ID configuration.
- Ensure the package name matches exactly.
Copyright 2025 Vedraj
Licensed under the Apache License, Version 2.0. You may obtain a copy at http://www.apache.org/licenses/LICENSE-2.0
Distributed on an "AS IS" basis, without warranties or conditions of any kind.