반응형

구글에서는 안드로이드 앱을 위해 Key-Value 방식자동 백업 방식의 두가지 방식을 지원한다.

 

1) Key-Value 방식
https://developer.android.google.cn/guide/topics/data/keyvaluebackup.html?authuser=19&hl=ko
위 링크를 보면 BackupAgent의 onBackup(), onRestore() 구현을 통해 쉽게 백업, 복원을 구현할 수 있다.

 

2) 자동 백업 방식
앱의 내부 저장소 폴더 내의 모든 파일에 대해 자동 백업을 수행하며 25MB의 사이즈 제한을 가진다.  

 

아래의 함수로 리턴되는 경로와 파일이 백업된다.

    공유 환경 설정 파일
    getFilesDir()
    getDir(String, int)을 사용하여 액세스하는 앱의 내부 저장소에 저장된 파일
    getDatabasePath(String)에서 반환한 디렉터리의 파일
    getExternalFilesDir(String)에서 반환한 디렉터리의 외부 저장소에 있는 파일


XML파일에 설정을 통해 백업 할 파일과 제외 파일을 명시적으로 설정할 수 있다.

- 자동 백업으로 사용자 데이터 백업
https://developer.android.google.cn/guide/topics/data/autobackup.html?authuser=19&hl=ko

- Codelab : 자동 백업 샘플앱
https://codelabs.developers.google.com/codelabs/android-backup-codelab/index.html?authuser=19&hl=ko#0

- 백업 서비스 등록
https://developer.android.google.cn/google/backup/signup?hl=ko&authuser=19

 

백업 및 복원 테스트를 위한 adb command 
    - bmgr - 다양한 백업 및 복원 작업 실행
        adb shell bmgr list transports  Google 백업 전송이 사용할 수 있고 활성화되어 있는지 확인  
        adb shell bmgr backupnow  key-value 백업을 시작
        adb shell bmgr fullbackup  자동 백업을 시작
        adb shell bmgr backup  BackupManager.dataChanged() 백업리스트에 포함
        adb shell bmgr run 백업 트리거
        adb shell bmgr restore   복원

    - Pending key/value backup 확인
        adb shell dumpsys backup  

반응형

+ Recent posts