Bash-script to automatically back up files in a given list via git version control
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

backup_routine.sh 782B

il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. IFS=$'\r\n' GLOBIGNORE='*' command eval 'FILES=($(cat backup_filelist.txt))'
  3. echo `date` >> log.txt
  4. for i in "${FILES[@]}"
  5. do
  6. FILENAME=$(basename "$i")
  7. if [ -f "$FILENAME" ]; then
  8. #echo "$FILENAME exists." >> log.txt
  9. DIF=$(diff "$i" "$FILENAME")
  10. if [ -z "$DIF" ]
  11. then
  12. echo "$FILENAME has not changed, skipping." >> log.txt
  13. else
  14. echo "$FILENAME has changed, copying..." >> log.txt
  15. cp "$i" .
  16. fi
  17. else
  18. echo "$FILENAME is a new file, copying..." >> log.txt
  19. cp "$i" .
  20. fi
  21. done
  22. if [[ `git status --porcelain` ]]; then
  23. echo "Git reports changes. Perfoming next generic commit." >> log.txt
  24. git add *
  25. git commit -m "next commit"
  26. else
  27. echo "Git doesn't report any changes. No new commit. Exiting." >> log.txt
  28. fi