Skip to content

Commit

Permalink
Use config-setup infrastructure to take backup of SONiC configuration…
Browse files Browse the repository at this point in the history
… (#715)

Used "config-setup backup" command to take a backup copy of current SONiC configuration.

Refer to sonic-net/SONiC#433 and sonic-net/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 <rajendra.dendukuri@broadcom.com>
  • Loading branch information
malletvapid23 committed Dec 4, 2019
1 parent a2d428f commit f5fb3fb
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions sonic_installer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit f5fb3fb

Please sign in to comment.