1 /* mdb_copy.c - memory-mapped database backup tool */
3 * Copyright 2012 Howard Chu, Symas Corp.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted only as authorized by the OpenLDAP
10 * A copy of this license is available in the file LICENSE in the
11 * top-level directory of the distribution or, alternatively, at
12 * <http://www.OpenLDAP.org/license.html>.
16 #define MDB_STDOUT GetStdHandle(STD_OUTPUT_HANDLE)
30 int main(int argc,char * argv[])
34 char *envname = argv[1];
36 if (argc<2 || argc>3) {
37 fprintf(stderr, "usage: %s srcpath [dstpath]\n", argv[0]);
42 signal(SIGPIPE, sighandle);
45 signal(SIGHUP, sighandle);
47 signal(SIGINT, sighandle);
48 signal(SIGTERM, sighandle);
50 rc = mdb_env_create(&env);
52 rc = mdb_env_open(env, envname, MDB_RDONLY, 0);
54 printf("mdb_env_open failed, error %d %s\n", rc, mdb_strerror(rc));
57 rc = mdb_env_copyfd(env, MDB_STDOUT);
59 rc = mdb_env_copy(env, argv[2]);
61 printf("mdb_env_copy failed, error %d %s\n", rc, mdb_strerror(rc));
65 return rc ? EXIT_FAILURE : EXIT_SUCCESS;