From f5fb3fb7df0b667a3db62d1d93ace9e53ff4f06a Mon Sep 17 00:00:00 2001 From: malletvapid23 Date: Wed, 4 Dec 2019 10:18:46 -0500 Subject: [PATCH] Use config-setup infrastructure to take backup of SONiC configuration (#715) Used "config-setup backup" command to take a backup copy of current SONiC configuration. Refer to Azure/SONiC#433 and Azure/sonic-buildimage#3227 for more information Added skip_migration option to "sonic_installer install" command to allow user to install an image with factory default configuration. Signed-off-by: Rajendra Dendukuri --- sonic_installer/main.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sonic_installer/main.py b/sonic_installer/main.py index b47703c..6e2cb30 100644 --- a/sonic_installer/main.py +++ b/sonic_installer/main.py @@ -312,8 +312,10 @@ def cli(): expose_value=False, prompt='New image will be installed, continue?') @click.option('-f', '--force', is_flag=True, help="Force installation of an image of a type which differs from that of the current running image") +@click.option('--skip_migration', is_flag=True, + help="Do not migrate current configuration to the newly installed image") @click.argument('url') -def install(url, force): +def install(url, force, skip_migration=False): """ Install image from local binary or URL""" cleanup_image = False if get_running_image_type() == IMAGE_TYPE_ABOOT: @@ -361,9 +363,11 @@ def install(url, force): else: run_command("bash " + image_path) run_command('grub-set-default --boot-directory=' + HOST_PATH + ' 0') - run_command("rm -rf /host/old_config") - # copy directories and preserve original file structure, attributes and associated metadata - run_command("cp -ar /etc/sonic /host/old_config") + # Take a backup of current configuration + if skip_migration: + click.echo("Skipping configuration migration as requested in the command option.") + else: + run_command('config-setup backup') # Finally, sync filesystem run_command("sync;sync;sync")