From: Austin Clements <amdragon@MIT.EDU>
To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
Subject: Re: [Patch v7 5/6] notmuch-new: backup tags before database upgrade
Date: Thu, 10 Apr 2014 09:25:57 -0400 [thread overview]
Message-ID: <8738hlxqmy.fsf@awakening.csail.mit.edu> (raw)
In-Reply-To: <1396712636-10640-6-git-send-email-david@tethera.net>
On Sat, 05 Apr 2014, David Bremner <david@tethera.net> 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
next prev parent reply other threads:[~2014-04-10 13:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-05 15:43 v7 gzip dump restore patches David Bremner
2014-04-05 15:43 ` [Patch v7 1/6] dump: support gzipped and atomic output David Bremner
2014-04-05 15:43 ` [Patch v7 2/6] util: add gz_readline David Bremner
2014-04-06 10:21 ` Tomi Ollila
2014-04-05 15:43 ` [Patch v7 3/6] test: restore with missing final newline David Bremner
2014-04-05 15:43 ` [Patch v7 4/6] restore: transparently support gzipped input David Bremner
2014-04-10 13:24 ` Austin Clements
2014-04-05 15:43 ` [Patch v7 5/6] notmuch-new: backup tags before database upgrade David Bremner
2014-04-10 13:25 ` Austin Clements [this message]
2014-04-05 15:43 ` [Patch v7 6/6] test: verify tag backup generated by " David Bremner
2014-04-10 13:27 ` v7 gzip dump restore patches Austin Clements
2014-04-12 11:32 ` David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8738hlxqmy.fsf@awakening.csail.mit.edu \
--to=amdragon@mit.edu \
--cc=david@tethera.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).