LoginSignup
30

More than 5 years have passed since last update.

adb backupのオプションについて

Posted at

adbのヘルプメッセージによると、adb backupコマンドにはいくつかオプションがある。説明文を日本語にしてみました。

adb backup [-f <file>] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all] [-system|-nosystem] [<packages...>]
                               - write an archive of the device's data to <file>.
                                 If no -f option is supplied then the data is written
                                 to "backup.ab" in the current directory.
                                 (-apk|-noapk enable/disable backup of the .apks themselves
                                    in the archive; the default is noapk.)
                                 (-obb|-noobb enable/disable backup of any installed apk expansion
                                    (aka .obb) files associated with each application; the default
                                    is noobb.)
                                 (-shared|-noshared enable/disable backup of the device's
                                    shared storage / SD card contents; the default is noshared.)
                                 (-all means to back up all installed applications)
                                 (-system|-nosystem toggles whether -all automatically includes
                                    system applications; the default is to include system apps)
                                 (<packages...> is the list of applications to be backed up.  If
                                    the -all or -shared flags are passed, then the package
                                    list is optional.  Applications explicitly given on the
                                    command line will be included even if -nosystem would
                                    ordinarily cause them to be omitted.)

もし-fオプションがなければ、カレントディレクトリの backup.ab ファイルに書き込まれる。
-apk,-noapkはAPKファイルの有無を指定する。デフォルトは-noapk(APKは含まない)。
-obb,-noobbはAPK拡張ファイルの有無を指定する。デフォルトは-noobb(拡張ファイルは含まない)。
-shared,-nosharedは共有ストレージ(SDカード)コンテンツの有無を指定する。デフォルトは-noshared(共有ストレージのデータは含まない)。
-allはインストールされている全てのアプリケーションをバックアップ対象にする(これを指定しない場合は、バックアップ対象のパッケージを個別に指定する)。
-system,-nosystem-allが自動的にシステムアプリケーションを含むかどうかを指定する。デフォルトは-system(システムアプリを含む)。
<packages...>はバックアップ対象のパッケージのリスト。-all-sharedフラグがある場合はこのパッケージリストは任意。ここで渡されたパッケージは-nosystemで除外されるパッケージだとしても含まれるようになる。

コマンド例

全てのアプリをバックアップする。

APK自体、拡張ファイル、共有ストレージのデータは含まない。バックアップ先は ./backup.ab

adb backup -all

全てのアプリのAPKと共有ストレージのデータをバックアップする。

拡張ファイルは含まない。バックアップ先は C:\backup20111230.ab

adb backup -apk -shared -all -f C:\backup20111230.ab

特定のアプリのみバックアップする。

com.eje_c.henshincamera, com.eje_c.hirudoco の二つのアプリのみバックアップする。拡張ファイルや共有ストレージのデータは含まない。バックアップ先は ./backup.ab

adb backup -apk com.eje_c.henshincamera com.eje_c.hirudoco

復元方法

adb restore <ファイル名>

ファイル名には、バックアップ時に作成された backup.ab などのファイルを指定する。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
30