Compare commits

..

No commits in common. "ee8c693f3b51b4140f75716231135f6c5a648b13" and "67906a920a8283cb0d6ff835da5cecbfd822587a" have entirely different histories.

3 changed files with 60 additions and 66 deletions

View File

@ -3,14 +3,14 @@ DESTDIR ?=
PREFIX ?= /usr/local
# Build flags
OPTS = -std=gnu99
FLAGS = -std=gnu99
# Build rules
all: backly
.PHONY: all install clean
backly: backly.c Makefile
gcc $(OPTS) $(CFLAGS) -o backly backly.c
gcc $(FLAGS) -o backly backly.c
install: backly
install -Dm 0755 backly $(DESTDIR)/$(PREFIX)/bin/backly

View File

@ -1,8 +1,5 @@
# backly
A simple directory cloner
## About backly
About backly
============
backly is a simple rsync-like tool for recursively copying entire directories.
The intended use case is for making verionless incremental backups; however, it
@ -11,25 +8,31 @@ provided you have read access to the source and write access to the
destination. Like rsync, backly uses a combination of file size and
modification date to determine if it needs to be copied over.
This program will **not** work properly if source is a subdirectory
This program will not work properly if source is a subdirectory
or destination or vice-versa.
## Required packages
Required packages
=================
backly does not depend on any packages other than what typically ships with any
Linux distribution.
## Installation
The usual `make` and `make install` is sufficient for compiling and installing
backly. The default prefix is `/usr/local`, which means the binary will be
installed to `/usr/local/bin`. The prefix can be changed by setting it in the
install command; for example, by running `make PREFIX=/usr install`.
Installation
============
## How to report bugs?
The usual 'make' and 'make install' is sufficient for compiling and installing
backly. The default prefix /usr/local, which means the binary will be installed
to /usr/local/bin. The prefix can be changed by setting it in the install
command; for example, by running 'make PREFIX=/usr install'.
Open an issue on the issue tracker.
How to report bugs?
===================
Bugs should be reported to L. Bradley LaBoon <me@bradleylaboon.com>
Please indicate what OS and architecture you are using, as well as output from
the program showing the bug, if possible (hint: run backly with `--test` to
avoid destroying any files that you care about).
the program showing the bug, if possible (hint: run backly with --test to avoid
destroying any files that you care about).

View File

@ -39,9 +39,8 @@ void printHelp()
printf("Turn destdir into a clone of srcdir.\n\n");
printf("Options:\n");
printf(" --test\t\tRun in test mode\n");
printf(" --noremove\tDon't remove any files in destdir\n");
printf(" --help\t\tPrint this help and quit\n\n");
printf(" --test\tRun in test mode.\n");
printf(" --help\tPrint this help and quit.\n\n");
printf("Report bugs to L. Bradley LaBoon <me@bradleylaboon.com>\n");
printf("backly home page: <http://git.bradleylaboon.com/backly.git>\n");
@ -268,7 +267,7 @@ void copyNew(char *src, int srcPrefix, char *dest, int destPrefix, int testMode)
fprintf(stderr, "Could not fork: %s\n", strerror(errno));
continue;
} else if (pid == 0) {
execlp("cp", "cp", "-f", "-P", "--preserve=timestamps,links", itemSrc, itemDest, (char *) NULL);
execlp("cp", "cp", "-fp", itemSrc, itemDest, (char *) NULL);
} else {
struct stat srcStat, destStat;
double pDone = 0;
@ -284,13 +283,8 @@ void copyNew(char *src, int srcPrefix, char *dest, int destPrefix, int testMode)
printf("\b \b");
numPrinted = printf("%.2lf%%", pDone * 100);
fflush(stdout);
usleep(50000);
}
}
for (int i = 0; i < numPrinted; i++)
printf("\b \b");
printf("100.00%%");
fflush(stdout);
}
}
printf("\n");
@ -305,7 +299,7 @@ void copyNew(char *src, int srcPrefix, char *dest, int destPrefix, int testMode)
int main(int argc, char **argv)
{
int srcArg = 0, destArg = 0;
int testMode = 0, remove = 1;
int testMode = 0;
// Parse arguments
for (int i = 1; i < argc; i++) {
@ -315,8 +309,6 @@ int main(int argc, char **argv)
} else if (strcmp(argv[i], "--test") == 0) {
testMode = 1;
printf("***Operating in test mode.***\n");
} else if (strcmp(argv[i], "--noremove") == 0) {
remove = 0;
} else if (srcArg == 0) {
srcArg = i;
} else {
@ -366,8 +358,7 @@ int main(int argc, char **argv)
closedir(dir);
// Remove files from the destination that don't exist in the source
if (remove)
removeMissing(srcDir, strlen(srcDir), destDir, strlen(destDir), testMode);
removeMissing(srcDir, strlen(srcDir), destDir, strlen(destDir), testMode);
// Copy new files and overwrite existing files if different
copyNew(srcDir, strlen(srcDir), destDir, strlen(destDir), testMode);