3 changed files with 392 additions and 0 deletions
@ -0,0 +1,28 @@ |
|||
TERMUX_PKG_HOMEPAGE=https://www.rsnapshot.org/ |
|||
TERMUX_PKG_DESCRIPTION="A remote filesystem snapshot utility" |
|||
TERMUX_PKG_LICENSE="GPL-2.0" |
|||
TERMUX_PKG_VERSION=1.4.3 |
|||
TERMUX_PKG_SRCURL=https://github.com/rsnapshot/rsnapshot/archive/$TERMUX_PKG_VERSION.tar.gz |
|||
TERMUX_PKG_SHA256=ab5f70f5b5db4f77f0156856bf4fd60eadb22b4dd6883bf4beb6d54b1bd4980d |
|||
TERMUX_PKG_DEPENDS="coreutils, openssh, perl, rsync" |
|||
TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" |
|||
--with-perl=$TERMUX_PREFIX/bin/perl |
|||
--with-rsync=$TERMUX_PREFIX/bin/rsync |
|||
--with-rm=$TERMUX_PREFIX/bin/rm |
|||
--with-ssh=$TERMUX_PREFIX/bin/ssh |
|||
--with-du=$TERMUX_PREFIX/bin/du |
|||
" |
|||
|
|||
TERMUX_PKG_CONFFILES="etc/rsnapshot.conf" |
|||
|
|||
termux_step_pre_configure() { |
|||
./autogen.sh |
|||
} |
|||
|
|||
termux_step_post_make_install() { |
|||
mkdir -p $TERMUX_PREFIX/etc |
|||
sed -e "s|@TERMUX_BASE_DIR@|/data/data/com.termux/files|g" \ |
|||
-e "s|@TERMUX_PREFIX@|$TERMUX_PREFIX|g" \ |
|||
-e "s|@TERMUX_HOME@|$TERMUX_ANDROID_HOME|g" \ |
|||
$TERMUX_PKG_BUILDER_DIR/rsnapshot.conf > $TERMUX_PREFIX/etc/rsnapshot.conf |
|||
} |
@ -0,0 +1,168 @@ |
|||
diff -uNr rsnapshot-1.4.3/rsnapshot-program.pl rsnapshot-1.4.3.mod/rsnapshot-program.pl
|
|||
--- rsnapshot-1.4.3/rsnapshot-program.pl 2019-11-17 03:57:50.000000000 +0200
|
|||
+++ rsnapshot-1.4.3.mod/rsnapshot-program.pl 2020-01-04 15:09:32.625965909 +0200
|
|||
@@ -2618,7 +2618,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 |
|||
@@ -3347,7 +3347,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 |
|||
# |
|||
@@ -3492,7 +3492,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/"); |
|||
@@ -4773,7 +4773,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(@_); |
|||
@@ -4786,10 +4786,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");
|
|||
} |
|||
} |
|||
|
|||
@@ -4802,31 +4802,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"; |
|||
@@ -4836,7 +4819,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); |
|||
} |
|||
@@ -4870,12 +4853,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); |
|||
} |
|||
@@ -4883,7 +4871,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 |
|||
@@ -6645,9 +6633,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 |
|||
@@ -6806,8 +6792,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/ |
|||
@@ -7204,9 +7189,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 |
|||
|
|||
@@ -7389,7 +7372,7 @@
|
|||
=back |
|||
|
|||
This will call the rsnapshot-diff program, which will scan both directories |
|||
-looking for differences (based on hard links).
|
|||
+looking for differences.
|
|||
|
|||
B<rsnapshot sync> |
|||
|
@ -0,0 +1,196 @@ |
|||
################################################# |
|||
# rsnapshot.conf - rsnapshot configuration file # |
|||
################################################# |
|||
# # |
|||
# PLEASE BE AWARE OF THE FOLLOWING RULE: # |
|||
# # |
|||
# This file requires tabs between elements # |
|||
# # |
|||
################################################# |
|||
|
|||
####################### |
|||
# CONFIG FILE VERSION # |
|||
####################### |
|||
|
|||
config_version 1.2 |
|||
|
|||
########################### |
|||
# SNAPSHOT ROOT DIRECTORY # |
|||
########################### |
|||
|
|||
# All snapshots will be stored under this root directory. |
|||
# |
|||
snapshot_root @TERMUX_BASE_DIR@/snapshots/ |
|||
|
|||
# If no_create_root is enabled, rsnapshot will not automatically create the |
|||
# snapshot_root directory. This is particularly useful if you are backing |
|||
# up to removable media, such as a FireWire or USB drive. |
|||
# |
|||
#no_create_root 1 |
|||
|
|||
################################# |
|||
# EXTERNAL PROGRAM DEPENDENCIES # |
|||
################################# |
|||
|
|||
cmd_rsnapshot_diff @TERMUX_PREFIX@/bin/rsnapshot-diff |
|||
|
|||
cmd_cp @TERMUX_PREFIX@/bin/cp |
|||
cmd_rm @TERMUX_PREFIX@/bin/rm |
|||
cmd_rsync @TERMUX_PREFIX@/bin/rsync |
|||
|
|||
# Uncomment this to enable remote ssh backups over rsync. |
|||
# |
|||
#cmd_ssh @TERMUX_PREFIX@/bin/ssh |
|||
|
|||
# Uncomment this to specify the path to "du" for disk usage checks. |
|||
# If you have an older version of "du", you may also want to check the |
|||
# "du_args" parameter below. |
|||
# |
|||
#cmd_du /data/data/com.termux/files/usr/bin/du |
|||
|
|||
# Specify the path to a script (and any optional arguments) to run right |
|||
# before rsnapshot syncs files |
|||
# |
|||
#cmd_preexec /path/to/preexec/script |
|||
|
|||
# Specify the path to a script (and any optional arguments) to run right |
|||
# after rsnapshot syncs files |
|||
# |
|||
#cmd_postexec /path/to/postexec/script |
|||
|
|||
######################################### |
|||
# BACKUP LEVELS / INTERVALS # |
|||
# Must be unique and in ascending order # |
|||
# e.g. alpha, beta, gamma, etc. # |
|||
######################################### |
|||
|
|||
retain alpha 6 |
|||
retain beta 7 |
|||
retain gamma 4 |
|||
#retain delta 3 |
|||
|
|||
############################################ |
|||
# GLOBAL OPTIONS # |
|||
# All are optional, with sensible defaults # |
|||
############################################ |
|||
|
|||
# Verbose level, 1 through 5. |
|||
# 1 Quiet Print fatal errors only |
|||
# 2 Default Print errors and warnings only |
|||
# 3 Verbose Show equivalent shell commands being executed |
|||
# 4 Extra Verbose Show extra verbose information |
|||
# 5 Debug mode Everything |
|||
# |
|||
verbose 2 |
|||
|
|||
# Same as "verbose" above, but controls the amount of data sent to the |
|||
# logfile, if one is being used. The default is 3. |
|||
# |
|||
loglevel 3 |
|||
|
|||
# If you enable this, data will be written to the file you specify. The |
|||
# amount of data written is controlled by the "loglevel" parameter. |
|||
# |
|||
#logfile @TERMUX_PREFIX@/var/log/rsnapshot |
|||
|
|||
# If enabled, rsnapshot will write a lockfile to prevent two instances |
|||
# from running simultaneously (and messing up the snapshot_root). |
|||
# If you enable this, make sure the lockfile directory is not world |
|||
# writable. Otherwise anyone can prevent the program from running. |
|||
# |
|||
lockfile @TERMUX_PREFIX@/var/run/rsnapshot.pid |
|||
|
|||
# By default, rsnapshot check lockfile, check if PID is running |
|||
# and if not, consider lockfile as stale, then start |
|||
# Enabling this stop rsnapshot if PID in lockfile is not running |
|||
# |
|||
#stop_on_stale_lockfile 0 |
|||
|
|||
# Default rsync args. All rsync commands have at least these options set. |
|||
# |
|||
#rsync_short_args -a |
|||
#rsync_long_args --delete --numeric-ids --relative --delete-excluded |
|||
|
|||
# ssh has no args passed by default, but you can specify some here. |
|||
# |
|||
#ssh_args -p 22 |
|||
|
|||
# Default arguments for the "du" program (for disk space reporting). |
|||
# The GNU version of "du" is preferred. See the man page for more details. |
|||
# If your version of "du" doesn't support the -h flag, try -k flag instead. |
|||
# |
|||
#du_args -csh |
|||
|
|||
# If this is enabled, rsync won't span filesystem partitions within a |
|||
# backup point. This essentially passes the -x option to rsync. |
|||
# The default is 0 (off). |
|||
# |
|||
#one_fs 0 |
|||
|
|||
# The include and exclude parameters, if enabled, simply get passed directly |
|||
# to rsync. If you have multiple include/exclude patterns, put each one on a |
|||
# separate line. Please look up the --include and --exclude options in the |
|||
# rsync man page for more details on how to specify file name patterns. |
|||
# |
|||
#include ??? |
|||
#include ??? |
|||
#exclude ??? |
|||
#exclude ??? |
|||
|
|||
# The include_file and exclude_file parameters, if enabled, simply get |
|||
# passed directly to rsync. Please look up the --include-from and |
|||
# --exclude-from options in the rsync man page for more details. |
|||
# |
|||
#include_file /path/to/include/file |
|||
#exclude_file /path/to/exclude/file |
|||
|
|||
# If your version of rsync supports --link-dest, consider enabling this. |
|||
# This is the best way to support special files (FIFOs, etc) cross-platform. |
|||
# The default is 0 (off). |
|||
# |
|||
#link_dest 0 |
|||
|
|||
# When sync_first is enabled, it changes the default behaviour of rsnapshot. |
|||
# Normally, when rsnapshot is called with its lowest interval |
|||
# (i.e.: "rsnapshot alpha"), it will sync files AND rotate the lowest |
|||
# intervals. With sync_first enabled, "rsnapshot sync" handles the file sync, |
|||
# and all interval calls simply rotate files. See the man page for more |
|||
# details. The default is 0 (off). |
|||
# |
|||
#sync_first 0 |
|||
|
|||
# If enabled, rsnapshot will move the oldest directory for each interval |
|||
# to [interval_name].delete, then it will remove the lockfile and delete |
|||
# that directory just before it exits. The default is 0 (off). |
|||
# |
|||
#use_lazy_deletes 0 |
|||
|
|||
# Number of rsync re-tries. If you experience any network problems or |
|||
# network card issues that tend to cause ssh to fail with errors like |
|||
# "Corrupted MAC on input", for example, set this to a non-zero value |
|||
# to have the rsync operation re-tried. |
|||
# |
|||
#rsync_numtries 0 |
|||
|
|||
############################### |
|||
### BACKUP POINTS / SCRIPTS ### |
|||
############################### |
|||
|
|||
# LOCALHOST |
|||
backup @TERMUX_HOME@ localhost/ |
|||
backup @TERMUX_PREFIX@ localhost/ |
|||
#backup_script @TERMUX_PREFIX@/bin/backup_pgsql.sh localhost/postgres/ |
|||
|
|||
# EXAMPLE.COM |
|||
#backup_exec @TERMUX_PREFIX@/bin/date "+ backup of example.com started at %c" |
|||
#backup root@example.com:/home/ example.com/ +rsync_long_args=--bwlimit=16,exclude=core |
|||
#backup root@example.com:/etc/ example.com/ exclude=mtab,exclude=core |
|||
#backup_exec ssh root@example.com "mysqldump -A > /var/db/dump/mysql.sql" |
|||
#backup root@example.com:/var/db/dump/ example.com/ |
|||
#backup_exec @TERMUX_PREFIX@/bin/date "+ backup of example.com ended at %c" |
|||
|
|||
# CVS.SOURCEFORGE.NET |
|||
#backup_script @TERMUX_PREFIX@/bin/backup_rsnapshot_cvsroot.sh rsnapshot.cvs.sourceforge.net/ |
|||
|
|||
# RSYNC.SAMBA.ORG |
|||
#backup rsync://rsync.samba.org/rsyncftp/ rsync.samba.org/rsyncftp/ |
Loading…
Reference in new issue