Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 89150431FBD for ; Thu, 10 Apr 2014 06:26:12 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8K53OS7Z2aiP for ; Thu, 10 Apr 2014 06:26:02 -0700 (PDT) Received: from dmz-mailsec-scanner-8.mit.edu (dmz-mailsec-scanner-8.mit.edu [18.7.68.37]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 09214431FBC for ; Thu, 10 Apr 2014 06:26:01 -0700 (PDT) X-AuditID: 12074425-f79906d000000cf9-24-53469be7cfcc Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) (using TLS with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP id 99.44.03321.7EB96435; Thu, 10 Apr 2014 09:25:59 -0400 (EDT) Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id s3ADPxpa028278; Thu, 10 Apr 2014 09:25:59 -0400 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s3ADPv6n016250 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Thu, 10 Apr 2014 09:25:58 -0400 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80) (envelope-from ) id 1WYEzN-0003EK-Eq; Thu, 10 Apr 2014 09:25:57 -0400 From: Austin Clements To: David Bremner , notmuch@notmuchmail.org Subject: Re: [Patch v7 5/6] notmuch-new: backup tags before database upgrade In-Reply-To: <1396712636-10640-6-git-send-email-david@tethera.net> References: <1396712636-10640-1-git-send-email-david@tethera.net> <1396712636-10640-6-git-send-email-david@tethera.net> User-Agent: Notmuch/0.17+167~g3863755 (http://notmuchmail.org) Emacs/23.4.1 (i486-pc-linux-gnu) Date: Thu, 10 Apr 2014 09:25:57 -0400 Message-ID: <8738hlxqmy.fsf@awakening.csail.mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrEIsWRmVeSWpSXmKPExsUixCmqrft8tluwwcwbNhY3WrsZLa7fnMns wOTxbNUtZo8th94zBzBFcdmkpOZklqUW6dslcGUsWriMteCJWMWLJb+YGhg/CnYxcnJICJhI LJqwhRHCFpO4cG89WxcjF4eQwGwmiR3XpjNCOBsZJWZPv8kE4Zxmkvi2qRUqs4RR4ty+Kawg /WwCGhLb9i8HmyUiYCfRc+E8O4gtLOAj8f79LiYQm1PASeL41DcsILaQQLlE76xGsBpRgXiJ 1n6IXhYBVYmDb/vYQGxeoPveNi9ih7AFJU7OfALWyyygJXHj30umCYwCs5CkZiFJLWBkWsUo m5JbpZubmJlTnJqsW5ycmJeXWqRroZebWaKXmlK6iREUlOwuqjsYJxxSOsQowMGoxMN7YJlr sBBrYllxZe4hRkkOJiVRXrVJbsFCfEn5KZUZicUZ8UWlOanFhxglOJiVRHg3TgXK8aYkVlal FuXDpKQ5WJTEed9aWwULCaQnlqRmp6YWpBbBZGU4OJQkeNNnATUKFqWmp1akZeaUIKSZODhB hvMADV8EUsNbXJCYW5yZDpE/xagoJc5rBpIQAElklObB9cKSxitGcaBXhHmLQKp4gAkHrvsV 0GAmoMGpdi4gg0sSEVJSDYzueSumyp3ceHV5/7P927IbZ/w/zqdyf6Xfm1m/+lKyjny7qsW3 RfHfSZesy7zfZ646lyiteie88ICWymtv1osZOxfV//t1vV5swq51SpcvnI6xUlIrKbm+dJPz wdp7hz1P7nL5OFFgXn555a6wH6t/uXXNXjq3S2bPq/PMbpPNGNYnt06Sv5zCrMRSnJFoqMVc VJwIAL+P8Fj1AgAA X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Apr 2014 13:26:18 -0000 On Sat, 05 Apr 2014, David Bremner wrote: > All we do here is calculate the backup filename, and call the existing > dump routine. > > Also take the opportity to add a message about being safe to opportunity > interrupt. > --- > notmuch-new.c | 29 ++++++++++++++++++++++++++++- > test/T530-upgrade.sh | 4 +++- > 2 files changed, 31 insertions(+), 2 deletions(-) > > diff --git a/notmuch-new.c b/notmuch-new.c > index 82acf69..d269c7c 100644 > --- a/notmuch-new.c > +++ b/notmuch-new.c > @@ -989,8 +989,35 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) > return EXIT_FAILURE; > > if (notmuch_database_needs_upgrade (notmuch)) { > - if (add_files_state.verbosity >= VERBOSITY_NORMAL) > + time_t now = time (NULL); > + struct tm *gm_time = gmtime (&now); > + > + /* since dump files are written atomically, the amount of > + * harm from overwriting one within a second seems > + * relatively small. */ > + > + const char *backup_name = > + talloc_asprintf (notmuch, "%s/dump-%04d%02d%02dT%02d%02d%02d.gz", > + dot_notmuch_path, > + gm_time->tm_year + 1900, > + gm_time->tm_mon + 1, > + gm_time->tm_mday, > + gm_time->tm_hour, > + gm_time->tm_min, > + gm_time->tm_sec); > + > + if (add_files_state.verbosity >= VERBOSITY_NORMAL) { > printf ("Welcome to a new version of notmuch! Your database will now be upgraded.\n"); > + printf ("This process is safe to interrupt.\n"); > + printf ("Backing up tags to %s...\n", backup_name); > + } > + > + if (notmuch_database_dump (notmuch, backup_name, "", > + DUMP_FORMAT_BATCH_TAG, TRUE)) { > + fprintf (stderr, "Backup failed. Aborting upgrade."); > + return EXIT_FAILURE; > + } > + > gettimeofday (&add_files_state.tv_start, NULL); > notmuch_database_upgrade (notmuch, > add_files_state.verbosity >= VERBOSITY_NORMAL ? upgrade_print_progress : NULL, > diff --git a/test/T530-upgrade.sh b/test/T530-upgrade.sh > index 67bbf31..d46e3d1 100755 > --- a/test/T530-upgrade.sh > +++ b/test/T530-upgrade.sh > @@ -26,9 +26,11 @@ output=$(notmuch search path:foo) > test_expect_equal "$output" "" > > test_begin_subtest "database upgrade from format version 1" > -output=$(notmuch new) > +output=$(notmuch new | sed -e 's/^Backing up tags to .*$/Backing up tags to FILENAME/') > test_expect_equal "$output" "\ > Welcome to a new version of notmuch! Your database will now be upgraded. > +This process is safe to interrupt. > +Backing up tags to FILENAME > Your notmuch database has now been upgraded to database format version 2. > No new mail." > > -- > 1.9.0 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch