Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Update list of tables for SC 3.4(-SP3)

...

Code Block
languagebash
themeRDark
linenumberstrue
#!/bin/env bash
cassandra_jg_host=${1:-localhost}
version=${version:-3.4}
syndeia_admin_pw=${syndeia_admin_pw:-myPw}
SC_HOME=${SC_HOME:-/opt/icx/syndeia-cloud-current}
keyspaces=(syndeia_cloud_auth syndeia_cloud_devops syndeia_cloud_graph syndeia_cloud_graph_config syndeia_cloud_store)
tables=(syndeia_cloud_storeauth.snapshotsauto_key \/
syndeia_cloud_storeauth.metadataconfig \/
syndeia_cloud_storeauth.offsetstoremessages \/
syndeia_cloud_storeauth.auto_keymetadata \/
syndeia_cloud_storeauth.messagesoffsetstore \/
syndeia_cloud_storeauth.repositoriessnapshots \/
syndeia_cloud_store.repositories_by_uri \auth.users /
syndeia_cloud_store.containers \auth.users_by_external_id /
syndeia_cloud_storeauth.containersusers_by_repositoryexternal_key \/
syndeia_cloud_storeauth.containersusers_by_externaluser_keyname \/
syndeia_cloud_store.containers_by_external_id \graph.edgestore /
syndeia_cloud_graph.edgestore_lock_ /
syndeia_cloud_storegraph.artifactsgraphindex \/
syndeia_cloud_storegraph.artifactsgraphindex_bylock_key \/
syndeia_cloud_storegraph.artifacts_by_container_key \janusgraph_ids /
syndeia_cloud_storegraph.artifacts_by_external_key \system_properties /
syndeia_cloud_storegraph.artifactssystem_byproperties_externallock_id \/
syndeia_cloud_store.artifacts_by_type_key \graph.systemlog /
syndeia_cloud_graph.txlog /
syndeia_cloud_graph_storeconfig.relationsedgestore \/
syndeia_cloud_graph_storeconfig.relationsedgestore_bylock_container_key \/
syndeia_cloud_storegraph_config.configgraphindex \/
syndeia_cloud_storegraph_config.relationsgraphindex_bylock_key \/
syndeia_cloud_graph_storeconfig.relations_by_external_id \janusgraph_ids /
syndeia_cloud_graph_storeconfig.relations_by_external_key \system_properties /
syndeia_cloud_storegraph_config.relationssystem_byproperties_sourcelock_key \/
syndeia_cloud_store.relations_by_target_key \graph_config.systemlog /
syndeia_cloud_store.repository_types \graph_config.txlog /
syndeia_cloud_store.containerartifact_types \/
syndeia_cloud_store.containerartifact_types_by_repositoryexternal_keyid \/
syndeia_cloud_store.containerartifact_types_by_external_key \/
syndeia_cloud_store.containerartifact_types_by_externalrepository_idkey \/
syndeia_cloud_store.artifact_typesartifacts \/
syndeia_cloud_store.artifactartifacts_types_by_repositorycontainer_key \/
syndeia_cloud_store.artifactartifacts_types_by_external_keyid \/
syndeia_cloud_store.artifactartifacts_types_by_external_idkey \/
syndeia_cloud_store.relationartifacts_by_typeskey \/
syndeia_cloud_store.relation_typesartifacts_by_repositorytype_key \/
syndeia_cloud_store.relation_types_by_external_auto_key \/
syndeia_cloud_store.relationconfig /
syndeia_cloud_store.container_types /
syndeia_cloud_store.container_types_by_external_id \/
syndeia_cloud_auth.snapshots \store.container_types_by_external_key /
syndeia_cloud_auth.metadata \store.container_types_by_repository_key /
syndeia_cloud_authstore.offsetstorecontainers \/
syndeia_cloud_auth.messages \store.containers_by_external_id /
syndeia_cloud_auth.config \store.containers_by_external_key /
syndeia_cloud_auth.auto_key \store.containers_by_repository_key /
syndeia_cloud_store.messages /
syndeia_cloud_authstore.usersmetadata \/
syndeia_cloud_auth.users_by_external_id \store.offsetstore /
syndeia_cloud_store.relation_types /
syndeia_cloud_authstore.usersrelation_types_by_external_keyid \/
syndeia_cloud_authstore.usersrelation_types_by_user_name)
LC_NUMERIC=C
# TIMEFORMAT='{"real":%R,"user":%U,"sys":%S}'
TIMEFORMAT='{"real":%R}'
if [[ ! -d SC_backups ]]; then
    mkdir SC_backups
fi;
echo "$(date) - Dump schema for ${keyspaces}..."
for keyspace in ${keyspaces[@]} do;
    dst_filenameexternal_key /
syndeia_cloud_store.relation_types_by_repository_key /
syndeia_cloud_store.relations /
syndeia_cloud_store.relations_by_container_key /
syndeia_cloud_store.relations_by_external_id /
syndeia_cloud_store.relations_by_external_key /
syndeia_cloud_store.relations_by_key /
syndeia_cloud_store.relations_by_source_key /
syndeia_cloud_store.relations_by_target_key /
syndeia_cloud_store.repositories /
syndeia_cloud_store.repositories_by_uri /
syndeia_cloud_store.repository_types /
syndeia_cloud_store.snapshots)
LC_NUMERIC=C
# TIMEFORMAT='{"real":%R,"user":%U,"sys":%S}'
TIMEFORMAT='{"real":%R}'
if [[ ! -d SC_backups ]]; then
    mkdir SC_backups
fi;
echo "$(date) - Dump schema for ${keyspaces}..."
for keyspace in ${keyspaces[@]} do;
    dst_filename="SC_backups/${keyspace}_schema_backup.cql"
    all_keyspace_filenames="${all_keyspace_filenames} ${keyspace}_schema_backup.cql"
    echo "$(date)   - Dump schema for ${keyspace}..."
    sudo cqlsh -u syndeia_admin -p ${syndeia_admin_pw} -e "DESCRIBE KEYSPACE ${keyspace};" "${cassandra_jg_host}" > ${dst_filename} > /dev/null
    if [[ $? -ne 0 ]]; then
        echo "$(date) x Error, could not export schema ${keyspace}"
        exit 1
    else
        echo "$(date) - Successfully exported schema ${keyspace}"
    fi;
	cat 
done;
cat "${all_keyspace_filenames}" > SC_backups/syndeia-cloud-${version}_concatenated_schema_backup.cql > /dev/null
echo "$(date) - Export data for tables..."
for table in ${tables[@]} do;
    dst_filename="SC_backups/syndeia-cloud-${version}_backup_${table}.csv"
	# Generate MD5 hash for NULL values during each table export
	md5hash=$(date -Iseconds | md5sum | cut -f1 -d' ')
	echo "${md5hash}" > SC_backups/${table}_md5hash_for_NULL.txt
    echo "$(date)  - Export data for ${table} to ${dst_filename} using md5hash=${md5hash} for NULL..."
    CQL_to_backup_table="COPY ${table} TO '${dst_filename}' WITH HEADER = TRUE AND NULL='${md5hash}'; "
    sudo cqlsh -u syndeia_admin -p ${syndeia_admin_pw} -e "${CQL_to_backup_table}" "${cassandra_jg_host}" > /dev/null
    if [[ $? -ne 0 ]]; then
        echo "$(date) x Error, could not export table ${table}"
        exit 2
    else
        echo "$(date) - Successfully exported table ${table}"
    fi;
done;

...

#!/bin/env bash cassandra_jg_host=${1:-localhost} version=${version:-3.4} syndeia_admin_pw=${syndeia_admin_pw:-myPw} SC_HOME=${SC_HOME:-/opt/icx/syndeia-cloud-current} keyspaces=(syndeia_cloud_auth syndeia_cloud_devops syndeia_cloud_graph syndeia_cloud_graph_config syndeia_cloud_store) tables=(syndeia_cloud_store.snapshots \ syndeia_cloud_store.metadata \ syndeia_cloud_store.offsetstore \ syndeia_cloud_store.auto_key \ syndeia_cloud_store.messages \ syndeia_cloud_store.repositories \ syndeia_cloud_store.repositories_by_uri \ syndeia_cloud_store.containers \ syndeia_cloud_store.containers_by_repository_key \ syndeia_cloud_store.containers_by_external_key \ syndeia_cloud_store.containers_by_external_id \ syndeia_cloud_store.artifacts \ syndeia_cloud_store.artifacts_by_key \
Code Block
languagebash
themeRDark
linenumberstrue
true
#!/bin/env bash
cassandra_jg_host=${1:-localhost}
version=${version:-3.4}
syndeia_admin_pw=${syndeia_admin_pw:-myPw}
SC_HOME=${SC_HOME:-/opt/icx/syndeia-cloud-current}
keyspaces=(syndeia_cloud_auth syndeia_cloud_devops syndeia_cloud_graph syndeia_cloud_graph_config syndeia_cloud_store)
tables=(syndeia_cloud_auth.auto_key /
syndeia_cloud_auth.config /
syndeia_cloud_auth.messages /
syndeia_cloud_auth.metadata /
syndeia_cloud_auth.offsetstore /
syndeia_cloud_auth.snapshots /
syndeia_cloud_auth.users /
syndeia_cloud_auth.users_by_external_id /
syndeia_cloud_auth.users_by_external_key /
syndeia_cloud_auth.users_by_user_name /
syndeia_cloud_graph.edgestore /
syndeia_cloud_graph.edgestore_lock_ /
syndeia_cloud_graph.graphindex /
syndeia_cloud_graph.graphindex_lock_ /
syndeia_cloud_graph.janusgraph_ids /
syndeia_cloud_graph.system_properties /
syndeia_cloud_graph.system_properties_lock_ /
syndeia_cloud_graph.systemlog /
syndeia_cloud_graph.txlog /
syndeia_cloud_graph_config.edgestore /
syndeia_cloud_graph_config.edgestore_lock_ /
syndeia_cloud_graph_config.graphindex /
syndeia_cloud_graph_config.graphindex_lock_ /
syndeia_cloud_graph_config.janusgraph_ids /
syndeia_cloud_graph_config.system_properties /
syndeia_cloud_graph_config.system_properties_lock_ /
syndeia_cloud_graph_config.systemlog /
syndeia_cloud_graph_config.txlog /
syndeia_cloud_store.artifact_types /
syndeia_cloud_store.artifact_types_by_external_id /
syndeia_cloud_store.artifact_types_by_external_key /
syndeia_cloud_store.artifact_types_by_repository_key /
syndeia_cloud_store.artifacts_by_container_key \ /
syndeia_cloud_store.artifacts_by_externalcontainer_key \/
syndeia_cloud_store.artifacts_by_external_id \/
syndeia_cloud_store.artifacts_by_typeexternal_key \/
syndeia_cloud_store.relations \artifacts_by_key /
syndeia_cloud_store.relationsartifacts_by_containertype_key \/
syndeia_cloud_store.configauto_key \/
syndeia_cloud_store.relations_by_key \config /
syndeia_cloud_store.relations_by_external_id \container_types /
syndeia_cloud_store.relationscontainer_types_by_external_keyid \/
syndeia_cloud_store.relationscontainer_types_by_sourceexternal_key \/
syndeia_cloud_store.relationscontainer_types_by_targetrepository_key \/
syndeia_cloud_store.repository_typescontainers \/
syndeia_cloud_store.container_types \containers_by_external_id /
syndeia_cloud_store.container_typescontainers_by_repositoryexternal_key \/
syndeia_cloud_store.containercontainers_types_by_externalrepository_key \/
syndeia_cloud_store.container_types_by_external_id \messages /
syndeia_cloud_store.artifact_typesmetadata \/
syndeia_cloud_store.artifact_types_by_repository_key \offsetstore /
syndeia_cloud_store.artifactrelation_types_by_external_key \ /
syndeia_cloud_store.artifactrelation_types_by_external_id \/
syndeia_cloud_store.relation_types \_by_external_key /
syndeia_cloud_store.relation_types_by_repository_key \/
syndeia_cloud_store.relation_typesrelations /
syndeia_cloud_store.relations_by_externalcontainer_key \/
syndeia_cloud_store.relation_typesrelations_by_external_id \/
syndeia_cloud_auth.snapshots \
syndeia_cloud_auth.metadata \
syndeia_cloud_auth.offsetstore \store.relations_by_external_key /
syndeia_cloud_auth.messages \store.relations_by_key /
syndeia_cloud_auth.config \store.relations_by_source_key /
syndeia_cloud_auth.autostore.relations_by_target_key \/
syndeia_cloud_authstore.usersrepositories \/
syndeia_cloud_authstore.usersrepositories_by_external_iduri \/
syndeia_cloud_authstore.users_by_external_key \repository_types /
syndeia_cloud_auth.users_by_user_namestore.snapshots)
LC_NUMERIC=C
# TIMEFORMAT='{"real":%R,"user":%U,"sys":%S}'
TIMEFORMAT='{"real":%R}'
echo "$(date) - Restore schema for ${keyspaces}..."
src_filename="SC_backups/syndeia-cloud-${version}_concatenated_schema_backup.cql"
sudo cqlsh -u syndeia_admin -p ${syndeia_admin_pw} -e "SOURCE '${src_filename}';" "${cassandra_jg_host}"
if [[ $? -ne 0 ]]; then
    echo "$(date) x Error, could not import concatenated schema ${src_filename}"
    exit 1
else
    echo "$(date) - Successfully imported concatenated schema ${src_filename}"
fi;
echo "$(date) - Import data for tables..."
for table in ${tables[@]} do;
    src_filename="SC_backups/syndeia-cloud-${version}_backup_${table}.csv"
	# Read MD5 hash for NULL values during each table export
	md5hash=$(cat SC_backups/${table}_md5hash_for_NULL.txt)
    echo "$(date)  - Import data for ${table} from ${dst_filename}..."
    CQL_to_restore_table="COPY ${table} FROM '${src_filename}' WITH HEADER = TRUE AND WITH NULL='${md5hash}'; "
    sudo cqlsh -u syndeia_admin -p ${syndeia_admin_pw} -e "${CQL_to_restore_table}" "${cassandra_jg_host}"
    if [[ $? -ne 0 ]]; then
        echo "$(date) x Error, could not import table ${table}"
        exit 2
    else
        echo "$(date) - Successfully imported table ${table}"
    fi;
done;
echo "$(date) - Done!"


...