0
0
mirror of https://github.com/termux/termux-packages.git synced 2025-03-04 08:18:54 +00:00
termux-packages/packages/rsnapshot/no-hard-links.patch
2025-02-25 15:39:38 +08:00

168 lines
5.6 KiB
Diff

--- a/rsnapshot-program.pl
+++ b/rsnapshot-program.pl
@@ -2627,7 +2627,7 @@
# same as $interval_max, except for the previous interval.
# this is used to determine which of the previous snapshots to pull from
- # e.g., cp -al alpha.$prev_interval_max/ beta.0/
+ # e.g., cp -a alpha.$prev_interval_max/ beta.0/
my $prev_interval_max;
# FIGURE OUT WHICH INTERVAL WE'RE RUNNING, AND HOW IT RELATES TO THE OTHERS
@@ -3367,7 +3367,7 @@
# operates on directories in the given interval (it should be the lowest one)
# deletes the highest numbered directory in the interval, and rotates the ones below it
# if link_dest is enabled, .0 gets moved to .1
-# otherwise, we do cp -al .0 .1
+# otherwise, we do cp -a .0 .1
#
# if we encounter an error, this script will terminate the program with an error condition
#
@@ -3519,7 +3519,7 @@
# otherwise, we hard link (except for directories, symlinks, and special files) sync to .0
else {
- # cp -al .sync .0
+ # cp -a .sync .0
if (-d "$config_vars{'snapshot_root'}/.sync/") {
display_cp_al("$config_vars{'snapshot_root'}/.sync/", "$config_vars{'snapshot_root'}/$interval.0/");
@@ -4813,7 +4813,7 @@
}
# accepts src, dest
-# prints out the cp -al command that would be run, based on config file data
+# prints out the cp -a command that would be run, based on config file data
sub display_cp_al {
my $src = shift(@_);
my $dest = shift(@_);
@@ -4826,10 +4826,10 @@
if (!defined($dest)) { bail('dest not defined in display_cp_al()'); }
if (defined($config_vars{'cmd_cp'})) {
- print_cmd("$config_vars{'cmd_cp'} -al $src $dest");
+ print_cmd("$config_vars{'cmd_cp'} -a $src $dest");
}
else {
- print_cmd("native_cp_al(\"$src\", \"$dest\")");
+ print_cmd("cp -a $src $dest");
}
}
@@ -4842,31 +4842,14 @@
my $dest = shift(@_);
my $result = 0;
- # use gnu cp if we have it
- if (defined($config_vars{'cmd_cp'})) {
- $result = gnu_cp_al("$src", "$dest");
-
- }
-
- # fall back to the built-in native perl replacement, followed by an rsync clean-up step
- else {
-
- # native cp -al
- $result = native_cp_al("$src", "$dest");
- if (1 != $result) {
- return ($result);
- }
-
- # rsync clean-up
- $result = rsync_cleanup_after_native_cp_al("$src", "$dest");
- }
+ $result = gnu_cp_al("$src", "$dest");
return ($result);
}
-# This is to test whether cp -al seems to work in a simple case
-# return 0 if cp -al succeeds
-# return 1 if cp -al fails
+# This is to test whether cp -a seems to work in a simple case
+# return 0 if cp -a succeeds
+# return 1 if cp -a fails
# return -1 if something else failed - test inconclusive
sub test_cp_al {
my $s = "$config_vars{'snapshot_root'}/cp_al1";
@@ -4876,7 +4859,7 @@
-d $s || mkdir($s) || return (-1);
open(TT1, ">>$s/tt1") || return (-1);
close(TT1) || return (-1);
- $result = system($config_vars{'cmd_cp'}, '-al', "$s", "$d");
+ $result = system($config_vars{'cmd_cp'}, '-a', "$s", "$d");
if ($result != 0) {
return (1);
}
@@ -4910,12 +4893,17 @@
}
# make the system call to GNU cp
- $result = system($config_vars{'cmd_cp'}, '-al', "$src", "$dest");
+ if (defined($config_vars{'cmd_cp'})) {
+ $result = system($config_vars{'cmd_cp'}, '-a', "$src", "$dest");
+ } else {
+ $result = system('cp', '-a', "$src", "$dest");
+ }
+
if ($result != 0) {
$status = $result >> 8;
- print_err("$config_vars{'cmd_cp'} -al $src $dest failed (result $result, exit status $status).", 2);
+ print_err("$config_vars{'cmd_cp'} -a $src $dest failed (result $result, exit status $status).", 2);
if (test_cp_al() > 0) {
- print_err("Perhaps your cp does not support -al options?", 2);
+ print_err("Perhaps your cp does not support -a option?", 2);
}
return (0);
}
@@ -4923,7 +4911,7 @@
return (1);
}
-# This is a purpose built, native perl replacement for GNU "cp -al".
+# This is a purpose built, native perl replacement for GNU "cp -a".
# However, it is not quite as good. it does not copy "special" files:
# block, char, fifo, or sockets.
# Never the less, it does do regular files, directories, and symlinks
@@ -6615,9 +6603,7 @@
B<rsnapshot> saves much more disk space than you might imagine. The amount
of space required is roughly the size of one full backup, plus a copy
-of each additional file that is changed. B<rsnapshot> makes extensive
-use of hard links, so if the file doesn't change, the next snapshot is
-simply a hard link to the exact same file.
+of each additional file that is changed.
B<rsnapshot> will typically be invoked as root by a cron job, or series
of cron jobs. It is possible, however, to run as any arbitrary user
@@ -6776,8 +6762,7 @@
<snapshot_root>/alpha.{1,2,3,4} will all be rotated +1, if they exist.
-<snapshot_root>/alpha.0/ will be copied to <snapshot_root>/alpha.1/
-using hard links.
+<snapshot_root>/alpha.0/ will be copied to <snapshot_root>/alpha.1/.
Each backup point (explained below) will then be rsynced to the
corresponding directories in <snapshot_root>/alpha.0/
@@ -7194,9 +7179,7 @@
rsnapshot will take the generated "mydatabase.sql" file and move it into the
<snapshot_root>/<retain>.0/db_backup/ directory. On subsequent runs,
rsnapshot checks the differences between the files created against the
-previous files. If the backup script generates the same output on the next
-run, the files will be hard linked against the previous ones, and no
-additional disk space will be taken up.
+previous files.
=back
@@ -7379,7 +7362,7 @@
=back
This will call the C<rsnapshot-diff> program, which will scan both directories
-looking for differences (based on hard links).
+looking for differences.
B<rsnapshot sync>