<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Libre Experience &#187; script</title>
	<atom:link href="http://www.libre-experience.org/index.php/tag/script/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.libre-experience.org</link>
	<description>Bloc-notes sur les logiciels libres</description>
	<lastBuildDate>Tue, 22 Nov 2011 07:21:41 +0000</lastBuildDate>
	<language>fr</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Sauvegarde différentielle sous Linux</title>
		<link>http://www.libre-experience.org/index.php/2008/02/09/sauvegarde-differentielle-sous-linux/</link>
		<comments>http://www.libre-experience.org/index.php/2008/02/09/sauvegarde-differentielle-sous-linux/#comments</comments>
		<pubDate>Sat, 09 Feb 2008 12:39:47 +0000</pubDate>
		<dc:creator>Marco</dc:creator>
				<category><![CDATA[Informatique]]></category>
		<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Planet-Libre]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[sauvegarde]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://88.191.51.26/wordpress/index.php/2008/02/09/sauvegarde-differentielle-sous-linux/</guid>
		<description><![CDATA[Toute la puissance de Linux&#8230; Ce script n&#8217;est pas de moi (je l&#8217;ai simplement légèrement adapté), mais j&#8217;ai malheureusement perdu la source&#8230; Il permet de gérer des sauvegardes différentielles avec historique. En plus grace à la technique des &#171;&#160;hardlinks&#160;&#187; la consommation en espace est minimale. Je l&#8217;utilise partout et franchement ça marche du feu de [...]]]></description>
			<content:encoded><![CDATA[<p>Toute la puissance de Linux&#8230; Ce script n&#8217;est pas de moi (je l&#8217;ai simplement légèrement adapté), mais j&#8217;ai malheureusement perdu la source&#8230;<br />
Il permet de gérer des sauvegardes différentielles avec historique. En plus grace à la technique des &laquo;&nbsp;<a href="http://en.wikipedia.org/wiki/Hard_link">hardlinks</a>&nbsp;&raquo; la consommation en espace est minimale. Je l&#8217;utilise partout et franchement ça marche du feu de de Dieu&#8230;<span id="more-10"></span></p>
<pre><code>
#!/bin/bash -x
#
# To launch it every day at 4AM, add the following line to /etc/crontab :
# 00 4 * * * root /usr/local/scripts/backupRsync.sh

### PARAMETRES A ADAPTER
LOGIN_USER="nom_utilisateur"
BACKUPSERVER="adresse_serveur"
SSH_PORT="port_ssh"
BACKUP_TO_DIR="repertoire_destination_backup"

DIRECTORIES2BACKUP="liste_des_reperoires_a_sauvegarder_separes_par_des_espaces"
EXCLUDES="liste_des_repertoires_ou_fichiers_a_exclure_separes_par_des_espaces"
NUMBER_OF_ARCHIVES=10
NICE_LEVEL=3
### FIN DES PARAMETRES A ADAPTER

#!/bin/bash
# ----------------------------------------------------------------------
# mikes handy rotating-filesystem-snapshot utility: daily snapshots
# See http://www.mikerubel.org/computers/rsync_snapshots/
# ----------------------------------------------------------------------

# make sure we're running as root
if (( `id -u` != 0 ));
then
  { echo "Sorry, must be root.  Exiting..."; exit; }
fi

# step 1: delete the oldest snapshot:
ssh -p $SSH_PORT -l $LOGIN_USER $BACKUPSERVER rm -rf \
    $BACKUP_TO_DIR/daily.$NUMBER_OF_ARCHIVES

# step 2: shift the middle snapshots(s) back by one, if they exist
for i in `seq $NUMBER_OF_ARCHIVES -1 2`; do
  PREVIOUS=`expr $i - 1`
  ssh -p $SSH_PORT -l $LOGIN_USER $BACKUPSERVER \
    mv $BACKUP_TO_DIR/daily.$PREVIOUS $BACKUP_TO_DIR/daily.$i
done

# step 3: make a hard-link-only (except for dirs) copy of the latest snapshot,
# if that exists

ssh -p $SSH_PORT -l $LOGIN_USER $BACKUPSERVER [ -d $BACKUP_TO_DIR/daily.0 ]
if [ $? -eq 0 ]
then
  echo "Moving DIRECTORY"
  ssh -p $SSH_PORT -l $LOGIN_USER $BACKUPSERVER \
    cp -al $BACKUP_TO_DIR/daily.0 $BACKUP_TO_DIR/daily.1
else
  echo "Creating DIRECTORY"
  ssh -p $SSH_PORT -l $LOGIN_USER $BACKUPSERVER mkdir $BACKUP_TO_DIR/daily.0
fi

# step 4: rsync from the system into the latest snapshot (notice that
# rsync behaves like cp --remove-destination by default, so the destination
# is unlinked first.  If it were not so, this would copy over the other
# snapshot(s) too!
for d in $DIRECTORIES2BACKUP
do
  nice --adjust $NICE_LEVEL rsync -va -e "ssh -p $SSH_PORT" --progress \
    --relative --delete --delete-excluded $EXCLUDES $d \
    $LOGIN_USER@$BACKUPSERVER:$BACKUP_TO_DIR/daily.0
done

# step 5: update the mtime of daily.0 to reflect the snapshot time
ssh -p $SSH_PORT -l $LOGIN_USER $BACKUPSERVER touch $BACKUP_TO_DIR/daily.0

</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.libre-experience.org/index.php/2008/02/09/sauvegarde-differentielle-sous-linux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

