onsdag 18 februari 2015

Linux Simple Bash h CP backup script

Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. clear
  2. kalladir=home/hynt
  3. backupdir=media/hynt/EXTERN/backup
  4. now=$(date +"%m_%d_%Y")
  5.  
  6. #Om mappen inte finns skapa den, detta är för slippa gnället om att mappen redan finns
  7.             [ ! -d  /$backupdir/$now/ ] && mkdir -p /$backupdir/$now/
  8.   [ ! -d /$backupdir/$now/Hämtningar/ ] && mkdir -p /$backupdir/$now/Hämtningar/
  9.     [ ! -d /$backupdir/$now/Dokument/ ] && mkdir -p /$backupdir/$now/Dokument/
  10.       [ ! -d /$backupdir/$now/Bilder/ ] && mkdir -p /$backupdir/$now/Bilder/
  11.        [ ! -d /$backupdir/$now/Musik/ ] && mkdir -p /$backupdir/$now/Musik/
  12.          [ ! -d /$backupdir/$now/PDF/ ] && mkdir -p /$backupdir/$now/PDF/
  13.      [ ! -d /$backupdir/$now/Projekt/ ] && mkdir -p /$backupdir/$now/Projekt/
  14.    [ ! -d /$backupdir/$now/Skrivbord/ ] && mkdir -p /$backupdir/$now/Skrivbord/
  15.     [ ! -d /$backupdir/$now/archives/ ] && mkdir -p /$backupdir/$now/archives/
  16.          [ ! -d /$backupdir/$now/tmp/ ] && mkdir -p /$backupdir/$now/tmp/
  17.     [ ! -d /$backupdir/$now/.mozilla/ ] && mkdir -p /$backupdir/$now/.mozilla/
  18. [ ! -d /$backupdir/$now/.thunderbird/ ] && mkdir -p /$backupdir/$now/.thunderbird/
  19.     [ ! -d /$backupdir/$now/archives/ ] && mkdir -p /$backupdir/$now/archives/
  20.     [ ! -d /$backupdir/$now/packages/ ] && mkdir -p /$backupdir/$now/packages/
  21.  
  22. echo "---------------------------------------------"
  23. echo "From: /$kalladir/"
  24. echo "To: /$backupdir/$now/"
  25. echo "---------------------------------------------"
  26. echo "Backup Folder: Bilder" && sudo cp -R -n /$kalladir/Bilder/ /$backupdir/$now/
  27. echo "Backup Folder: Dokument" && sudo cp -R -n /$kalladir/Dokument/ /$backupdir/$now/
  28. echo "Backup Folder: Hämtningar" && sudo cp -R -n /$kalladir/Hämtningar/ /$backupdir/$now/
  29. echo "Backup Folder: Musik" && sudo cp -R -n /$kalladir/Musik/ /$backupdir/$now/
  30. echo "Backup Folder: PDF" && sudo cp -R -n /$kalladir/PDF/ /$backupdir/$now/
  31. echo "Backup Folder: Projekt" && sudo cp -R -n /$kalladir/Projekt/ /$backupdir/$now/
  32. echo "Backup Folder: Skrivbord" && sudo cp -R -n /$kalladir/Skrivbord/ /$backupdir/$now/
  33. echo "Backup Folder: tmp" && sudo cp -R -n /$kalladir/tmp/ /$backupdir/$now/
  34. echo "Backup Folder: Video" && sudo cp -R -n /$kalladir/Video/ /$backupdir/$now/
  35. echo "Backup Folder: .mozilla" && sudo cp -R -n /$kalladir/.mozilla/ /$backupdir/$now/
  36. echo "Backup Folder: .thunderbird" && sudo cp -R -n /$kalladir/.thunderbird/ /$backupdir/$now/
  37. echo "Backup File: .bash_aliases" && sudo cp -R -n /$kalladir/.bash_aliases /$backupdir/$now/
  38. echo "Backup File: .bashrc " && sudo cp -R -n /$kalladir/.bashrc /$backupdir/$now/
  39. echo "Backup Folder: .archives" && sudo cp -R -n /var/cache/apt/archives/*.deb /$backupdir/$now/archives/
  40.  
  41. cd /$backupdir/$now/
  42. sudo dpkg --get-selections > /$backupdir/$now/packages/Package.list
  43. sudo cp -R /etc/apt/ /$backupdir/$now/packages/
  44. sudo apt-key exportall > /$backupdir/$now/packages/Repo.keys

Inga kommentarer: