PNG  IHDR* pHYs+ IDATx]n#; cdLb Ǚ[at¤_:uP}>!Usă cag޿ ֵNu`ݼTâabO7uL&y^wFٝA"l[|ŲHLN밪4*sG3|Dv}?+y߉{OuOAt4Jj.u]Gz*҉sP'VQKbA1u\`& Af;HWj hsO;ogTu uj7S3/QzUr&wS`M$X_L7r2;aE+ώ%vikDA:dR+%KzƉo>eOth$z%: :{WwaQ:wz%4foɹE[9<]#ERINƻv溂E%P1i01 |Jvҗ&{b?9g=^wζXn/lK::90KwrюO\!ջ3uzuGv^;騢wq<Iatv09:tt~hEG`v;3@MNZD.1]L:{ծI3`L(÷ba")Y.iljCɄae#I"1 `3*Bdz>j<fU40⨬%O$3cGt]j%Fߠ_twJ;ABU8vP3uEԑwQ V:h%))LfraqX-ۿX]v-\9I gl8tzX ]ecm)-cgʒ#Uw=Wlێn(0hPP/ӨtQ“&J35 $=]r1{tLuǮ*i0_;NƝ8;-vݏr8+U-kruȕYr0RnC]*ެ(M:]gE;{]tg(#ZJ9y>utRDRMdr9㪩̞zֹb<ģ&wzJM"iI( .ꮅX)Qw:9,i좜\Ԛi7&N0:asϓc];=ΗOӣ APqz93 y $)A*kVHZwBƺnWNaby>XMN*45~ղM6Nvm;A=jֲ.~1}(9`KJ/V F9[=`~[;sRuk]rєT!)iQO)Y$V ی ۤmzWz5IM Zb )ˆC`6 rRa}qNmUfDsWuˤV{ Pݝ'=Kֳbg,UҘVz2ﴻnjNgBb{? ߮tcsͻQuxVCIY۠:(V뺕 ٥2;t`@Fo{Z9`;]wMzU~%UA蛚dI vGq\r82iu +St`cR.6U/M9IENDB` REDROOM
PHP 5.6.40
Preview: atomic-rsync Size: 3.90 KB
//proc/thread-self/root/usr/share/doc/rsync/support/atomic-rsync

#!/usr/bin/perl
#
# This script lets you update a hierarchy of files in an atomic way by
# first creating a new hierarchy using rsync's --link-dest option, and
# then swapping the hierarchy into place.  **See the usage message for
# more details and some important caveats!**

use strict;
use warnings;
use Cwd 'abs_path';

my $RSYNC_PROG = '/usr/bin/rsync';
my $RM_PROG = '/bin/rm';

my $dest_dir = $ARGV[-1];
&usage if !defined $dest_dir || $dest_dir =~ /(^-|^$)/ || grep(/^--help/, @ARGV);
$dest_dir =~ s{(?<=.)/+$} {};

if (!-d $dest_dir) {
    die "$dest_dir is not a directory.\nUse --help for help.\n";
}

if (@_ = grep(/^--[a-z]+-dest\b/, @ARGV)) {
    $_ = join(' or ', @_);
    die "You cannot use the $_ option with atomic-rsync.\nUse --help for help.\n";
}

my $symlink_content = readlink $dest_dir; # undef when a real dir

my $dest_arg = $dest_dir;
# This gives us the real destination dir, with all symlinks dereferenced.
$dest_dir = abs_path($dest_dir);
if ($dest_dir eq '/') {
    die qq|You must not use "/" as the destination directory.\nUse --help for help.\n|;
}

my($old_dir, $new_dir);
if (defined $symlink_content && $dest_dir =~ /-([12])$/) {
    my $num = 3 - $1;
    $old_dir = undef;
    ($new_dir = $dest_dir) =~ s/-[12]$/-$num/;
    $symlink_content =~ s/-[12]$/-$num/;
} else {
    $old_dir = "$dest_dir~old~";
    $new_dir = "$dest_dir~new~";
}

$ARGV[-1] = "$new_dir/";

system($RM_PROG, '-rf', $old_dir) if defined $old_dir && -d $old_dir;
system($RM_PROG, '-rf', $new_dir) if -d $new_dir;

if (system($RSYNC_PROG, "--link-dest=$dest_dir", @ARGV)) {
    if ($? == -1) {
	print "failed to execute $RSYNC_PROG: $!\n";
    } elsif ($? & 127) {
	printf "child died with signal %d, %s coredump\n",
	    ($? & 127),  ($? & 128) ? 'with' : 'without';
    } else {
	printf "child exited with value %d\n", $? >> 8;
    }
    exit $?;
}

if (!defined $old_dir) {
    atomic_symlink($symlink_content, $dest_arg);
    exit;
}

rename($dest_dir, $old_dir) or die "Unable to rename $dest_dir to $old_dir: $!";
rename($new_dir, $dest_dir) or die "Unable to rename $new_dir to $dest_dir: $!";

exit;

sub atomic_symlink
{
    my($target, $link) = @_;
    my $newlink = "$link~new~";

    unlink($newlink); # Just in case
    symlink($target, $newlink) or die "Unable to symlink $newlink -> $target: $!\n";
    rename($newlink, $link) or die "Unable to rename $newlink to $link: $!\n";
}


sub usage
{
    die <<EOT;
Usage: atomic-rsync [RSYNC-OPTIONS] HOST:/SOURCE/DIR/ /DEST/DIR/
       atomic-rsync [RSYNC-OPTIONS] HOST::MOD/DIR/ /DEST/DIR/

This script lets you update a hierarchy of files in an atomic way by first
creating a new hierarchy (using hard-links to leverage the existing files),
and then swapping the new hierarchy into place.  You must be pulling files
to a local directory, and that directory must already exist.  For example:

    mkdir /local/files-1
    ln -s files-1 /local/files
    atomic-rsync -av host:/remote/files/ /local/files/

If /local/files is a symlink to a directory that ends in -1 or -2, the
copy will go to the alternate suffix and the symlink will be changed to
point to the new dir.  This is a fully atomic update.  If the destination
is not a symlink (or not a symlink to a *-1 or a *-2 directory), this
will instead create a directory with "~new~" suffixed, move the current
directory to a name with "~old~" suffixed, and then move the ~new~
directory to the original destination name (this double rename is not
fully atomic, but is rapid).  In both cases, the prior destintaion
directory will be preserved until the next update, at which point it
will be deleted.

In all likelihood, you do NOT want to specify this command:

    atomic-rsync -av host:/remote/files /local/

... UNLESS you want the entire /local dir to be swapped out!

See the "rsync" command for its list of options.  You may not use the
--link-dest, --compare-dest, or --copy-dest options (since this script
uses --link-dest to make the transfer efficient).
EOT
}

Directory Contents

Dirs: 0 × Files: 20

Name Size Perms Modified Actions
3.90 KB lrw-r--r-- 2008-10-11 16:30:26
Edit Download
1.18 KB lrw-r--r-- 2007-03-21 13:51:54
Edit Download
997 B lrw-r--r-- 2008-06-28 17:12:57
Edit Download
4.82 KB lrw-r--r-- 2006-12-20 00:50:17
Edit Download
534 B lrw-r--r-- 2006-01-30 21:52:17
Edit Download
910 B lrw-r--r-- 2009-01-13 22:52:03
Edit Download
2.72 KB lrw-r--r-- 2009-01-13 22:52:03
Edit Download
1.07 KB lrw-r--r-- 2005-10-04 04:12:28
Edit Download
2.21 KB lrw-r--r-- 2013-06-10 02:40:56
Edit Download
956 B lrw-r--r-- 2013-06-10 02:40:56
Edit Download
80 B lrw-r--r-- 2005-01-11 18:37:37
Edit Download
629 B lrw-r--r-- 2008-11-16 02:32:21
Edit Download
621 B lrw-r--r-- 2008-11-16 02:32:21
Edit Download
1.80 KB lrw-r--r-- 2011-07-04 23:32:06
Edit Download
1.43 KB lrw-r--r-- 2007-11-27 15:34:59
Edit Download
7.07 KB lrw-r--r-- 2015-09-13 23:23:54
Edit Download
267 B lrw-r--r-- 2014-01-01 18:35:08
Edit Download
643 B lrw-r--r-- 2012-01-28 18:42:01
Edit Download
8.48 KB lrw-r--r-- 2016-01-31 22:40:51
Edit Download
4.45 KB lrw-r--r-- 2006-12-18 07:24:24
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).
© 2026 REDROOM — Secure File Manager. All rights reserved. Built with ❤️ & Red Dark UI