[ovs-dev] [db-backup 5/5] Avoid unneeded database compaction at startup, and improve backups.

Ethan Jackson ethan at nicira.com
Tue Feb 15 00:19:42 UTC 2011


>
> I tested the xenserver version but not the Debian version.
> ---
>  debian/openvswitch-switch.init   |   13 ++++++++-----
>  xenserver/etc_init.d_openvswitch |   15 ++++++++-------
>  2 files changed, 16 insertions(+), 12 deletions(-)
>
> diff --git a/debian/openvswitch-switch.init b/debian/openvswitch-switch.init
> index 60cc369..dd75e78 100755
> --- a/debian/openvswitch-switch.init
> +++ b/debian/openvswitch-switch.init
> @@ -226,12 +226,15 @@ case "$1" in
>         if test ! -e $conf_file; then
>             # Create configuration database.
>             ovsdb-tool -vANY:console:emer create $conf_file $schema_file
> -        else
> -            # If schema version changed, then back up the old version.
> -            old_ver=`ovsdb-tool db-version "$conf_file"`
> -            if test "X$old_ver" != "X$schema_ver"; then
> -                cp "$conf_file" "$conf_file.backup$old_ver"
> +        elif test "X`ovsdb-tool needs-conversion $conf_file $schema_file`" != Xno; then
> +            # Back up the old version.
> +            suffix=`ovsdb-tool db-version "$conf_file"`
> +            backup=$conf_file.backup$suffix
> +            if test -e "$backup"; then
> +                suffix=`ovsdb-tool db-cksum "$conf_file" | awk '{print $1}'`
> +                backup=$conf_file.backup$suffix

I think this is fine.  However, we could alternatively always use the
db-version and the checksum in the backup file name saving the need to
check if it exists and having the added benefit of consistency.  At
any rate, looks good go ahead and merge when you're ready.

Ethan




More information about the dev mailing list