Pharos 0.7.23
Modern Web Framework & Web App Hosting Service.
Loading...
Searching...
No Matches
native_backup_restore.c File Reference

Implements native backup and restore reporting for app state and sqlite snapshots. More...

#include "native_backup_restore.h"
#include "native_artifact_emit.h"
#include "native_fs.h"
#include "native_json_config.h"
#include "native_support.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

Go to the source code of this file.

Macros

#define native_backup_restore_strdup   strdup

Functions

static char * native_default_backend_local (const AppRuntime *app)
static char * native_default_sqlite_path_local (const AppRuntime *app)
static char * native_app_conf_path (const char *app_root)
static char * native_app_conf_value_path (const char *app_root, const char *key)
static char * native_backup_base_dir (const AppRuntime *app)
static char * native_backup_timestamp_utc (void)
static long native_json_top_level_long (const char *text, const char *key, long fallback_value)
static char * native_migration_fixture_path (const AppRuntime *app)
static long native_migration_schema_version (const char *migration_fixture_path)
static int native_write_backup_state_snapshot (const AppRuntime *app, const char *output_path)
static char * native_metadata_artifact_value (const char *metadata_path, const char *key)
char * build_native_backup_report_local_json (const ServeConfig *config, const AppRuntime *app, const char *backend_override, const char *output_dir_override, char **error_out)
 Builds a JSON report describing a native app backup operation.
char * build_native_restore_report_local_json (const ServeConfig *config, const AppRuntime *app, const char *backend_override, const char *input_dir, char **error_out)
 Builds a JSON report describing a native app restore operation.

Detailed Description

Implements native backup and restore reporting for app state and sqlite snapshots.

Definition in file native_backup_restore.c.

Macro Definition Documentation

◆ native_backup_restore_strdup

Function Documentation

◆ build_native_backup_report_local_json()

char * build_native_backup_report_local_json ( const ServeConfig * config,
const AppRuntime * app,
const char * backend_override,
const char * output_dir_override,
char ** error_out )

Builds a JSON report describing a native app backup operation.

Parameters
configActive serve configuration.
appFinalized app runtime to back up.
backend_overrideOptional backend override.
output_dir_overrideOptional output directory override.
error_outOptional destination for an allocated error message.
Returns
Newly allocated JSON report text, or NULL on failure.

Definition at line 217 of file native_backup_restore.c.

References copy_file_binary(), ensure_directory(), json_string_dup_native(), native_backup_base_dir(), native_backup_restore_strdup, native_backup_timestamp_utc(), native_default_backend_local(), native_default_sqlite_path_local(), native_migration_fixture_path(), native_migration_schema_version(), native_write_backup_state_snapshot(), path_exists(), path_join(), streq(), ServeConfig::target_id, and write_text_file().

Referenced by handle_native_backup_restore_ops_command().

◆ build_native_restore_report_local_json()

char * build_native_restore_report_local_json ( const ServeConfig * config,
const AppRuntime * app,
const char * backend_override,
const char * input_dir,
char ** error_out )

Builds a JSON report describing a native app restore operation.

Parameters
configActive serve configuration.
appFinalized app runtime to restore into.
backend_overrideOptional backend override.
input_dirDirectory containing restore input artifacts.
error_outOptional destination for an allocated error message.
Returns
Newly allocated JSON report text, or NULL on failure.

Definition at line 366 of file native_backup_restore.c.

References copy_file_binary(), ensure_directory(), json_string_dup_native(), native_backup_restore_strdup, native_default_backend_local(), native_default_sqlite_path_local(), native_metadata_artifact_value(), path_dirname(), path_exists(), path_join(), AppRuntime::state_path, streq(), and ServeConfig::target_id.

Referenced by handle_native_backup_restore_ops_command().

◆ native_app_conf_path()

char * native_app_conf_path ( const char * app_root)
static

Definition at line 44 of file native_backup_restore.c.

References path_exists(), and path_join().

Referenced by native_app_conf_value_path().

◆ native_app_conf_value_path()

char * native_app_conf_value_path ( const char * app_root,
const char * key )
static

◆ native_backup_base_dir()

char * native_backup_base_dir ( const AppRuntime * app)
static

◆ native_backup_timestamp_utc()

char * native_backup_timestamp_utc ( void )
static

◆ native_default_backend_local()

char * native_default_backend_local ( const AppRuntime * app)
static

◆ native_default_sqlite_path_local()

char * native_default_sqlite_path_local ( const AppRuntime * app)
static

◆ native_json_top_level_long()

long native_json_top_level_long ( const char * text,
const char * key,
long fallback_value )
static

Definition at line 123 of file native_backup_restore.c.

Referenced by native_migration_schema_version().

◆ native_metadata_artifact_value()

char * native_metadata_artifact_value ( const char * metadata_path,
const char * key )
static

◆ native_migration_fixture_path()

char * native_migration_fixture_path ( const AppRuntime * app)
static

◆ native_migration_schema_version()

long native_migration_schema_version ( const char * migration_fixture_path)
static

◆ native_write_backup_state_snapshot()

int native_write_backup_state_snapshot ( const AppRuntime * app,
const char * output_path )
static