info:howtobackupubuntu:howto:sauvegarder_toutes_vos_donnees_avant_une_migration_ou_un_upgrade_sur_une_ubuntu_ou_toute_autre_distribution_linux

Sauvegarder toutes vos données

vieilleries… j'ai maintenant un NAS et changé ma politique de Backups

p. ex. avant une migration ou un upgrade sur une ubuntu (ou toute autre distribution linux)

keywords: backup

#!/bin/bash
############################################################################
#    Copyright (C) 2011 by fradeff@akademia.ch                             #
#                                                                          #
#    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.,                                       #
#    59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             #
############################################################################
# Usage:
# sauvegarder.sh

# Required:
# tar, gzip, rsync, killbakall

# Optional:
# apache, php, ufw, mysql

# Authors:
# FR, Frederic.Radeff@adm.unige.ch, University of Geneva

# History
#  --- //[[fradeff@akademia.ch|Fred Radeff]] 2008/06/18 13:51// FR, created
#  --- //[[fradeff@akademia.ch|Fred Radeff]] 2011/02/02 18:01// FR, mod
#########################
## BEGIN VARIABLES ##
#definir les chemins
chemin="/backups"
#maison
maison="/home/radeff"
#definir le fichier backup sql
filesql="$maison/$(date +'%Y%m%d')allMySQLdb.sql"
#serveur distant pour backup
distant="radeff@truc:"$maison
### END VARIABLES - no change after if u don't know what u are doing! ###
###################################################################

touch $filesql

# putz: on vide les corbeilles #
rm -fR /root/.Trash/*
rm -fR $maison/.Trash/*
#using my litte ruby script killbakall to remove all backup files eg test~
cd /root
killbakall
cd $maison
killbakall


### BACKUPS ###
#sauver config réseau (+ sûr: aussi faire à la main avec des screenshot et surtout IMPRIMER)
#en effet indispensable après pour la réinstallation de ubuntu!!!
ifconfig -a > $maison/configurationReseau

#faire des snapshot des mots de passe firefox; 
#Pour les bookmarks, c'est conservé dans $HOMEDIR/.mozilla/..., mais plus simple d'en faire un au cas où

#sauver config firewall (ufw)
sudo cp /var/lib/ufw/user.rules $maison

#sauver config printer (todo)
mkdir $maison/printers
cp /etc/cups/cupsd.conf $maison/printers
cd $maison/printers
wget http://localhost:631/printers

#sauver bases mysql
#faire le ménage avant avec  show databases; puis drop database xxx;
mysqldump -u[usr] -p[passwd] --all-databases --add-drop-table > $filesql

# backup crontabs
crontab -l > $maison/mycrontabs

#backup installed software
dpkg --get-selections > $maison/selections.sav

#backup apache conf
tar -cvf $maison/apache.tar /etc/apache2
gzip $maison/apache.tar

#backup root
tar -cvf $maison/root.tar /root
gzip $maison/root.tar

#backup apache DocumentRoot
tar -cvf $maison/www.tar /var/www
gzip $maison/www.tar

#backup various
ls -alF / > $maison/rootFiles

echo "# syncing all"
############# syncing all ###########3
rsync -avz $maison/* $chemin $maison

#tar all if needed
#tar -cvf $chemin/home.tar $maison
#gzip $chemin/home.tar


#if needed, you may now make a rsync with a remote server, eg
#rsync $chemin/home.tar radeff@

FIXME: todo: restore un script pour récupérer sur une autre machine le résultat du script ci-dessus

FIXME remplacer firestarter par ufw

killbak

dpkg

ufw

Voir aussi

  • info/howtobackupubuntu/howto/sauvegarder_toutes_vos_donnees_avant_une_migration_ou_un_upgrade_sur_une_ubuntu_ou_toute_autre_distribution_linux.txt
  • Dernière modification : 2024/02/21 06:13
  • de radeff