Backup on that install.\n"); exit(1); } $error = null; $meta = backupInspectArchive($file, $key, $error); if ($meta === false) { fwrite(STDERR, "Cannot read this backup: $error\n"); exit(1); } echo "Backup archive: " . basename($file) . "\n"; echo "Size: " . backupFormatBytes(filesize($file)) . "\n"; echo "Type: " . backupTypeLabel($meta['type']) . "\n"; echo "Taken: " . $meta['generated'] . "\n"; echo "ITFlow version: " . $meta['app_version'] . "\n"; echo "Database version:" . " " . $meta['database_version'] . "\n"; echo "Contains: " . implode(", ", $meta['entries']) . "\n"; $current_db_version = backupCurrentDatabaseVersion($mysqli); echo "This install is at database version $current_db_version.\n"; if (isset($options['inspect'])) { echo "\n--inspect given, nothing was changed.\n"; exit(0); } if ($meta['database_version'] !== 'Unknown' && version_compare($meta['database_version'], $current_db_version, '>')) { echo "\nWARNING: this backup is from a NEWER database version than the code in this directory.\n"; echo "Update ITFlow to a matching version before restoring, or the app will error after the restore.\n"; } echo "\n"; echo "This will REPLACE the database"; if (in_array('uploads.zip', $meta['entries'], true)) { echo " and everything in the uploads folder"; } echo ".\n"; echo "The current database is dumped first and put back automatically if the restore fails.\n"; if (!isset($options['yes'])) { echo "\nType 'restore' to continue: "; $answer = trim(fgets(STDIN) ?: ''); if ($answer !== 'restore') { echo "Aborted, nothing was changed.\n"; exit(1); } } echo "\n"; $restore_error = null; $ok = backupRestoreArchive($mysqli, $file, $key, $restore_error, function ($message) { echo " $message\n"; }); if (!$ok) { fwrite(STDERR, "\nRestore failed: $restore_error\n"); exit(1); } logAudit("Backup", "Restore", "Restored from " . escapeSql(basename($file)) . " via the command line"); echo "\nDone.\n"; echo "\nNext steps:\n"; echo " 1. Log in with the credentials that were in use when the backup was taken.\n"; echo " 2. If the backup is older than the code in this directory, finish the database update:\n"; echo " php " . realpath(__DIR__) . "/update_cli.php --update_db\n"; echo " 3. Check Settings > Cron - the schedule came back with the database.\n"; exit(0);