Bash snippets: Unterschied zwischen den Versionen
Aus Vosp.info
F (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „Shell/bash befehle = kleine Skripte = == backup entwicklerumgebung ==“) |
F (Diskussion | Beiträge) (→backup entwicklerumgebung) |
||
Zeile 4: | Zeile 4: | ||
== backup entwicklerumgebung == | == backup entwicklerumgebung == | ||
+ | |||
+ | |||
+ | <source lang=bash> | ||
+ | today=$(date "+%Y%m%d_%H%M") | ||
+ | basisPath="/mnt/c/Users/user/dev/" | ||
+ | backupFile="$1_$today$2.tar" | ||
+ | backupPath="/mnt/c/Users/user/backups/" | ||
+ | |||
+ | echo -e "\nbackup $backupFile" | ||
+ | date | ||
+ | |||
+ | cd $basisPath | ||
+ | |||
+ | # exclude strategy | ||
+ | #tar --exclude='images' --exclude='vendor' --exclude='webfonts' --exclude='bootstrap' --exclude='fontawesome-free-6.2.0-web' -czf $backupPath/$backupFile.gz $1 | ||
+ | |||
+ | |||
+ | # include strategy | ||
+ | find ./$1 -name "*.php" -o -name "*.scss" -name "*.css" -name "*.js" -name "*.sql" -name "*.TXT" -name "*." -name "*." | tar -cf $backupPath/$backupFile -T - | ||
+ | |||
+ | #gunzip archive.tar.gz | ||
+ | tar -rf $backupPath/$backupFile $1/.git | ||
+ | gzip $backupPath/$backupFile | ||
+ | |||
+ | ls -lahrt $backupPath/$backupFile* | ||
+ | date | ||
+ | echo -e "\n" | ||
+ | </source> |
Version vom 13. November 2024, 10:11 Uhr
kleine Skripte
backup entwicklerumgebung
today=$(date "+%Y%m%d_%H%M")
basisPath="/mnt/c/Users/user/dev/"
backupFile="$1_$today$2.tar"
backupPath="/mnt/c/Users/user/backups/"
echo -e "\nbackup $backupFile"
date
cd $basisPath
# exclude strategy
#tar --exclude='images' --exclude='vendor' --exclude='webfonts' --exclude='bootstrap' --exclude='fontawesome-free-6.2.0-web' -czf $backupPath/$backupFile.gz $1
# include strategy
find ./$1 -name "*.php" -o -name "*.scss" -name "*.css" -name "*.js" -name "*.sql" -name "*.TXT" -name "*." -name "*." | tar -cf $backupPath/$backupFile -T -
#gunzip archive.tar.gz
tar -rf $backupPath/$backupFile $1/.git
gzip $backupPath/$backupFile
ls -lahrt $backupPath/$backupFile*
date
echo -e "\n"