La sauvegarde se fait en 3 étapes :

  • Etape 1 : Connexion au serveur (192.168.1.1) via mount -t smbfs. En cas d'erreur, le script est arrété.
  • Etape 2 : Création de l'archive
  • Etape 3 : Déconnexion du serveur (umount).

Je vous livre le script qui demande quelques adaptations en fonction de vos fichiers ou répertoires à sauvegarder.

#!/bin/sh
###############################################################################
#
# Sauvegarde sur serveur
#
# by Guillaume Kulakowski a.k.a LLaumgui <guillaume at llaumgui dot com>
# Version 1.0
#
###############################################################################
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not,
#  - write to the Free Software
#               Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#       - See http://www.gnu.org/licenses/gpl.html
###############################################################################

echo "------------------------------------------------------";
echo "- Sauvegarde système";
echo "------------------------------------------------------";
echo "";


echo "Etape 1 : Connection au serveur de backup";
if ! mount -t smbfs -o ip=192.168.1.1,username=xxx,password=xxx //192.168.1.1/serv_backup /mnt/backup/ ;
then exit;
fi
echo "------------------------------------------------------";
echo "";


echo "Etape 2 : Création de l'archive";
date=`date +%m%d%y`;
tar -cf /mnt/backup/backup_${date}.tar "/etc/" "/home/llaumgui/" "/usr/share/themes/" "/usr/share/icons/" "/usr/share/pixmaps/"
echo "------------------------------------------------------";
echo "";


echo "Etape 3 : Déconnection du serveur";
umount /mnt/backup
echo "------------------------------------------------------";
echo "";

echo "### Fin de la sauvegarde <img src="/themes/default/smilies/smile.png" alt=":)" class="smiley" /> ###";