Outils pour utilisateurs

Outils du site


usbbackup:backups_automatiques_sur_disque_usb_insere

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
usbbackup:backups_automatiques_sur_disque_usb_insere [2021/11/30 16:03] ghussonusbbackup:backups_automatiques_sur_disque_usb_insere [2024/08/28 07:51] (Version actuelle) ghusson
Ligne 11: Ligne 11:
  
 </code> </code>
- 
  
  
Ligne 25: Ligne 24:
 #!/bin/bash #!/bin/bash
 # apt install beep udisks2 # apt install beep udisks2
- +  
 + 
 LOG_FILE=$0.log LOG_FILE=$0.log
 # CHANGEME :::: # CHANGEME ::::
Ligne 35: Ligne 34:
 RSYNC_PATHS[2]="/opt/" RSYNC_PATHS[2]="/opt/"
 RSYNC_PATHS[3]="/root/" RSYNC_PATHS[3]="/root/"
- +  
 + 
 horoDate() horoDate()
 { {
   echo $(date "+%Y%m%d-%H%M%S")   echo $(date "+%Y%m%d-%H%M%S")
 } }
- +  
 + 
 function uptime_int() function uptime_int()
 { {
Ligne 61: Ligne 60:
   fi   fi
 } }
- +  
 +  
 errorBeep() errorBeep()
 { {
   beep  -f 220  -l 800 -d 200 -r 4   beep  -f 220  -l 800 -d 200 -r 4
 } }
- +  
 + 
 tooSoonBeep() tooSoonBeep()
 { {
   beep  -f 1600  -l 100 -d 20 -r 4   beep  -f 1600  -l 100 -d 20 -r 4
 } }
 + 
    
 victoryBeep() victoryBeep()
Ligne 106: Ligne 105:
  }  }
    
-  + 
-echo "===============================================================================" >> $LOG_FILE+ echo "===============================================================================" >> $LOG_FILE
 echo "$(horoDate) New usb device detected: $1." >> $LOG_FILE echo "$(horoDate) New usb device detected: $1." >> $LOG_FILE
    
Ligne 116: Ligne 115:
 fi fi
    
 + 
 if [ -e /dev/disk/by-label/$PARTITION_LABEL ]; then if [ -e /dev/disk/by-label/$PARTITION_LABEL ]; then
   echo "$(horoDate) Partition label \"$PARTITION_LABEL\" found." >> $LOG_FILE   echo "$(horoDate) Partition label \"$PARTITION_LABEL\" found." >> $LOG_FILE
Ligne 124: Ligne 123:
     for RSYNC_PATH in ${RSYNC_PATHS[*]}; do     for RSYNC_PATH in ${RSYNC_PATHS[*]}; do
       echo "$(horoDate) Rsync "$RSYNC_PATH" to $MOUNT_POINT/$(basename $RSYNC_PATH)">> $LOG_FILE       echo "$(horoDate) Rsync "$RSYNC_PATH" to $MOUNT_POINT/$(basename $RSYNC_PATH)">> $LOG_FILE
-      rsync -aAX --delete --delete-before "$RSYNC_PATH" $MOUNT_POINT/$(basename $RSYNC_PATH) >> $LOG_FILE 2>&1+      rsync -aAX --delete --delete-before "$RSYNC_PATH" $MOUNT_POINT/$(basename $RSYNC_PATH) >> $LOG_FILE 2>&
     done     done
     echo "$(horoDate) Backup ended, unmounting partition, shutting off disk and signal end of script." >> $LOG_FILE     echo "$(horoDate) Backup ended, unmounting partition, shutting off disk and signal end of script." >> $LOG_FILE
Ligne 142: Ligne 141:
     errorBeep     errorBeep
     exit 2     exit 2
-  fi+  fi 
 else else
   echo "$(horoDate) Partition label \"$PARTITION_LABEL\" no found, end of script." >> $LOG_FILE   echo "$(horoDate) Partition label \"$PARTITION_LABEL\" no found, end of script." >> $LOG_FILE
Ligne 148: Ligne 147:
   errorBeep   errorBeep
   exit 3   exit 3
-fi+
  
 </code> </code>
Ligne 177: Ligne 176:
 <code> <code>
 systemctl daemon-reload systemctl daemon-reload
 +udevadm control --reload-rules && udevadm trigger
 systemctl restart systemd-udevd systemctl restart systemd-udevd
 </code> </code>
 +
 +
 +Pour créer un disque de backup :
 +  * faire une table de partition GPT
 +  * créer 1 partition de type Linux, avec le label correspondant à $PARTITION_LABEL
 +  * formater la partition
 +  * tester
 +
  
usbbackup/backups_automatiques_sur_disque_usb_insere.1638288238.txt.gz · Dernière modification : 2021/11/30 16:03 de ghusson