Skip to content

[fast-reboot] Backup database after syncd/swss stopped #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions scripts/fast-reboot
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,19 @@ function wait_for_pre_shutdown_complete_or_fail()
function backup_database()
{
debug "Backing up database ..."

if [[ "$REBOOT_TYPE" = "fastfast-reboot" || "$REBOOT_TYPE" = "fast-reboot" ]]; then
# Advanced reboot: dump state to host disk
sonic-db-cli ASIC_DB FLUSHDB > /dev/null
sonic-db-cli COUNTERS_DB FLUSHDB > /dev/null
sonic-db-cli FLEX_COUNTER_DB FLUSHDB > /dev/null
fi

if [[ "$REBOOT_TYPE" = "fast-reboot" ]]; then
# Flush RESTAP_DB in fast-reboot to avoid stale status
sonic-db-cli RESTAPI_DB FLUSHDB > /dev/null
fi

# Dump redis content to a file 'dump.rdb' in warmboot directory
mkdir -p $WARM_DIR
# Delete keys in stateDB except FDB_TABLE|*, MIRROR_SESSION_TABLE|*, WARM_RESTART_ENABLE_TABLE|*, FG_ROUTE_TABLE|*
Expand Down Expand Up @@ -753,23 +766,11 @@ for service in ${SERVICES_TO_STOP}; do
wait_for_pre_shutdown_complete_or_fail
fi

if [[ "$REBOOT_TYPE" = "fastfast-reboot" || "$REBOOT_TYPE" = "fast-reboot" ]]; then
# Advanced reboot: dump state to host disk
sonic-db-cli ASIC_DB FLUSHDB > /dev/null
sonic-db-cli COUNTERS_DB FLUSHDB > /dev/null
sonic-db-cli FLEX_COUNTER_DB FLUSHDB > /dev/null
fi

if [[ "$REBOOT_TYPE" = "fast-reboot" ]]; then
# Flush RESTAP_DB in fast-reboot to avoid stale status
sonic-db-cli RESTAPI_DB FLUSHDB > /dev/null
fi

backup_database

fi
done

backup_database

# Stop the docker container engine. Otherwise we will have a broken docker storage
systemctl stop docker.service || debug "Ignore stopping docker service error $?"

Expand Down
Loading