summaryrefslogtreecommitdiffstats
path: root/source/tdb
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2002-06-28 03:52:22 +0000
committerAndrew Tridgell <tridge@samba.org>2002-06-28 03:52:22 +0000
commitae2f8aa9d0678aa0014d96fc8b1b52f42cba8349 (patch)
tree7ef0d9473874e5024d162ccdbfe55f580b17cded /source/tdb
parentabc2aed26c6cb12a86987a3846ca5c9f7df9a5ae (diff)
downloadsamba-ae2f8aa9d0678aa0014d96fc8b1b52f42cba8349.tar.gz
samba-ae2f8aa9d0678aa0014d96fc8b1b52f42cba8349.tar.xz
samba-ae2f8aa9d0678aa0014d96fc8b1b52f42cba8349.zip
don't backup to a newer file
Diffstat (limited to 'source/tdb')
-rw-r--r--source/tdb/tdbbackup.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/source/tdb/tdbbackup.c b/source/tdb/tdbbackup.c
index 48c4272d331..f59f98a90f5 100644
--- a/source/tdb/tdbbackup.c
+++ b/source/tdb/tdbbackup.c
@@ -224,6 +224,21 @@ static int verify_tdb(const char *fname, const char *bak_name)
}
+/*
+ see if one file is newer than another
+*/
+static int file_newer(const char *fname1, const char *fname2)
+{
+ struct stat st1, st2;
+ if (stat(fname1, &st1) != 0) {
+ return 0;
+ }
+ if (stat(fname2, &st2) != 0) {
+ return 1;
+ }
+ return (st1.st_mtime > st2.st_mtime);
+}
+
static void usage(void)
{
printf("Usage: tdbbackup [options] <fname...>\n\n");
@@ -276,7 +291,8 @@ static void usage(void)
ret = 1;
}
} else {
- if (backup_tdb(fname, bak_name) != 0) {
+ if (file_newer(fname, bak_name) &&
+ backup_tdb(fname, bak_name) != 0) {
ret = 1;
}
}