Skip to content

Commit d3d985a

Browse files
rajendra-dendukurilguohan
authored andcommitted
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 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 <[email protected]>
1 parent 4e272c3 commit d3d985a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

sonic_installer/main.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,10 @@ def cli():
312312
expose_value=False, prompt='New image will be installed, continue?')
313313
@click.option('-f', '--force', is_flag=True,
314314
help="Force installation of an image of a type which differs from that of the current running image")
315+
@click.option('--skip_migration', is_flag=True,
316+
help="Do not migrate current configuration to the newly installed image")
315317
@click.argument('url')
316-
def install(url, force):
318+
def install(url, force, skip_migration=False):
317319
""" Install image from local binary or URL"""
318320
cleanup_image = False
319321
if get_running_image_type() == IMAGE_TYPE_ABOOT:
@@ -361,9 +363,11 @@ def install(url, force):
361363
else:
362364
run_command("bash " + image_path)
363365
run_command('grub-set-default --boot-directory=' + HOST_PATH + ' 0')
364-
run_command("rm -rf /host/old_config")
365-
# copy directories and preserve original file structure, attributes and associated metadata
366-
run_command("cp -ar /etc/sonic /host/old_config")
366+
# Take a backup of current configuration
367+
if skip_migration:
368+
click.echo("Skipping configuration migration as requested in the command option.")
369+
else:
370+
run_command('config-setup backup')
367371

368372
# Finally, sync filesystem
369373
run_command("sync;sync;sync")

0 commit comments

Comments
 (0)