summaryrefslogtreecommitdiffstats
path: root/zarb-ml/mageia-dev/2012-October/019712.html
blob: a6624a97239efd659a7bb15c3caaecd06a806b65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
 <HEAD>
   <TITLE> [Mageia-dev] Distrib-coffee big failure of the century
   </TITLE>
   <LINK REL="Index" HREF="index.html" >
   <LINK REL="made" HREF="mailto:mageia-dev%40mageia.org?Subject=Re%3A%20%5BMageia-dev%5D%20Distrib-coffee%20big%20failure%20of%20the%20century&In-Reply-To=%3C5091A63A.70403%40zen.co.uk%3E">
   <META NAME="robots" CONTENT="index,nofollow">
   <META http-equiv="Content-Type" content="text/html; charset=us-ascii">
   <LINK REL="Previous"  HREF="019673.html">
   <LINK REL="Next"  HREF="019713.html">
 </HEAD>
 <BODY BGCOLOR="#ffffff">
   <H1>[Mageia-dev] Distrib-coffee big failure of the century</H1>
    <B>Barry Jackson</B> 
    <A HREF="mailto:mageia-dev%40mageia.org?Subject=Re%3A%20%5BMageia-dev%5D%20Distrib-coffee%20big%20failure%20of%20the%20century&In-Reply-To=%3C5091A63A.70403%40zen.co.uk%3E"
       TITLE="[Mageia-dev] Distrib-coffee big failure of the century">zen25000 at zen.co.uk
       </A><BR>
    <I>Wed Oct 31 23:29:14 CET 2012</I>
    <P><UL>
        <LI>Previous message: <A HREF="019673.html">[Mageia-dev] Distrib-coffee big failure of the century
</A></li>
        <LI>Next message: <A HREF="019713.html">[Mageia-dev] Distrib-coffee big failure of the century
</A></li>
         <LI> <B>Messages sorted by:</B> 
              <a href="date.html#19712">[ date ]</a>
              <a href="thread.html#19712">[ thread ]</a>
              <a href="subject.html#19712">[ subject ]</a>
              <a href="author.html#19712">[ author ]</a>
         </LI>
       </UL>
    <HR>  
<!--beginarticle-->
<PRE>On 30/10/12 21:49, Barry Jackson wrote:
&gt;<i> On 30/10/12 21:29, Johnny A. Solbu wrote:
</I>&gt;&gt;<i> On Tuesday 30 October 2012 22:21, Barry Jackson wrote:
</I>&gt;&gt;&gt;<i> I will set --max-delete=500 locally in future.
</I>&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;<i> Any better ideas?
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> I always run rsync manually twice. The first run I use &#171;-n&#187; to make
</I>&gt;&gt;<i> sure my mirror isn't wiped, and then run rsync normally.
</I>&gt;&gt;<i>
</I>&gt;<i>
</I>&gt;<i> I run it from a cron job via a script, so I could parse the output of a
</I>&gt;<i> dry run and count deletes for example, then let it decide whether to run
</I>&gt;<i> or not.
</I>&gt;<i> Thanks - worth investigating :)
</I>&gt;<i>
</I>I wrote the attached script. It checks several mirrors until it finds 
one that has the normal number of files and does not fail for any other 
reason.

Currently I have distrib-coffee at the top of the possible mirror list, 
but it is skipped because it only has a fraction of the files yet.

It creates a couple of logs and runs as a cron job (or manually).

If you feel inclined to use it please feel free to suggest any improvements.

I certainly feel safer now.

Barry
-------------- next part --------------
#!/bin/bash
# ~/cronsync
# Run with e.g. crontab:- 30 * * * *	$HOME/cronsync
# Set using crontab -e
###################
# List of mirrors in preference order to use:-
mymirrors=( \
&quot;<A HREF="rsync://distrib-coffee.ipsl.jussieu.fr:/pub/linux/Mageia/distrib">rsync://distrib-coffee.ipsl.jussieu.fr:/pub/linux/Mageia/distrib</A>&quot; \
&quot;<A HREF="rsync://ftp.LinuxCabal.org/Mageia/distrib">rsync://ftp.LinuxCabal.org/Mageia/distrib</A>&quot; \
&quot;<A HREF="rsync://ftp.acc.umu.se/mirror/mageia/distrib">rsync://ftp.acc.umu.se/mirror/mageia/distrib</A>&quot; \
&quot;<A HREF="rsync://mirrors.kernel.org:/mirrors/mageia/distrib">rsync://mirrors.kernel.org:/mirrors/mageia/distrib</A>&quot; \
&quot;<A HREF="rsync://mageia.c3sl.ufpr.br/mageia/distrib">rsync://mageia.c3sl.ufpr.br/mageia/distrib</A>&quot; \
)
# Set limit for loss of # of files on server before it is skipped
allowdropfiles=100
###################
# Personal config:-
myexcludes=&quot;--exclude=debug --exclude=SRPMS --exclude=barjac&quot;
mydestination=&quot;/zmrepo/pub/linux/Mageia/&quot;
###################

# Get minimum file count for mirror (set at allowdropfiles files less than the last actual file count)
[[ -f .cronsync ]] || echo &quot;140000&quot; &gt; $HOME/.cronsync
minfiles=$(cat .cronsync)
((actualfiles = $minfiles + $allowdropfiles))
# Check a mirror
chk_mirror()
{
echo &quot;Checking $1 ...&quot;
chkout=$(rsync -rlptgoDhHSn \
--stats \
--delete-after \
--delete \
--delete-excluded \
--protect-args \
$myexcludes \
&quot;$1&quot; \
&quot;$mydestination&quot; | grep &quot;Number of files:&quot; )
status1=&quot;$?&quot;
files=$(echo $chkout | cut -d' ' -f4)
[[ $files -lt $minfiles ]] &amp;&amp; echo &quot;$(date +%d/%m/%Y-%H:%M): Only $files/$actualfiles files in $1 !&quot; | tee -a $HOME/cronsync_error.log
[[ $status1 &gt; 0 ]] &amp;&amp; echo &quot;$(date +%d/%m/%Y-%H:%M): Error: $status1 while checking $1&quot; | tee -a $HOME/cronsync_error.log
([[ $status1 = 0 ]] &amp;&amp; [[ $files -gt $minfiles ]]) || return 1
((chkcount = $files - $allowdropfiles))
echo $chkcount &gt; $HOME/.cronsync
return 0
}

# Loop through mirror list checking until one succeeds
find_good_mirror()
{
for mirr in ${mymirrors[@]}; do
chk_mirror $mirr
[[ $? = 0 ]] &amp;&amp; { echo &quot;Found good mirror - $mirr&quot;; return 0; }
done
return 1
}

#=======================Main Program starts here=====================

# Check if rsync is already running (maybe last cron sync taking for ever?)
ps aux | grep -q [r]sync
if [[ $? &gt; 0 ]]; then

# Find a good mirror from the list (with files in it)
find_good_mirror || { echo &quot;$(date +%d/%m/%Y-%H:%M) Can't find a good mirror - aborting&quot; | tee -a $HOME/cronsync_error.log; exit 1; }

echo &quot;Syncing from $mirr ...&quot;

# Live run with --max-delete set to 1000 just in case ;)
rsync -rlptgoDhHS \
--progress \
--stats \
--delete-after \
--delete \
--max-delete=1000 \
--delete-excluded \
--protect-args \
$myexcludes \
&quot;$mirr&quot; \
&quot;$mydestination&quot; | tee $HOME/cronsync_last.log

status=$?
[[ $status = 0 ]] &amp;&amp; { echo &quot;Update complete&quot;; exit 0; }
[[ $status &gt; 0 ]] &amp;&amp; { echo &quot;Live run error - $(date +%d/%m/%Y-%H:%M) = $status&quot; &gt;&gt; $HOME/cronsync_error.log; exit 1; }
else
echo &quot;rsync already running, skipping update - $(date +%d/%m/%Y-%H:%M)&quot; &gt;&gt; $HOME/cronsync_error.log
exit 1
fi
</PRE>


<!--endarticle-->
    <HR>
    <P><UL>
        <!--threads-->
	<LI>Previous message: <A HREF="019673.html">[Mageia-dev] Distrib-coffee big failure of the century
</A></li>
	<LI>Next message: <A HREF="019713.html">[Mageia-dev] Distrib-coffee big failure of the century
</A></li>
         <LI> <B>Messages sorted by:</B> 
              <a href="date.html#19712">[ date ]</a>
              <a href="thread.html#19712">[ thread ]</a>
              <a href="subject.html#19712">[ subject ]</a>
              <a href="author.html#19712">[ author ]</a>
         </LI>
       </UL>

<hr>
<a href="https://www.mageia.org/mailman/listinfo/mageia-dev">More information about the Mageia-dev
mailing list</a><br>
</body></html>