private void backupInternal(final Runnable runAfterwards, final boolean autobackup) {
        final Folder backupDir = getNewBackupFolder(System.currentTimeMillis(), autobackup);
        if (backupDir == null) {
            ViewUtils.showToast(activityContext, R.string.init_backup_folder_exists_error);
            return;
        }

        final AtomicBoolean tracksResult = new AtomicBoolean(true);
        AndroidRxUtils.andThenOnUi(Schedulers.io(),
            () -> {
                // copy trackfiles in background
                tracksResult.set(FolderUtils.get().copyAll(Folder.fromFile(LocalStorage.getTrackfilesDir()), Folder.fromFolder(backupDir, TRACKS_SUBFOLDER), false).result == FolderUtils.ProcessResult.OK);
            },
            () -> {
                // copy settings
                final boolean settingsResult = createSettingsBackupInternal(backupDir, Settings.getBackupLoginData());

                // copy database and display result
                final Consumer<Boolean> consumer = dbResult -> {
                    showBackupCompletedStatusDialog(backupDir, tracksResult.get(), settingsResult, dbResult, autobackup);

                    if (runAfterwards != null) {
                        runAfterwards.run();
                    }
                };
                createDatabaseBackupInternal(backupDir, consumer);
            });
    }
Private methods containing the real backup process
main/src/main/java/cgeo/geocaching/utils/BackupUtils.java