Created
February 28, 2022 21:24
-
-
Save ogabrielguerra/baa6ac402498dc9a0a06d0e703e2c3b7 to your computer and use it in GitHub Desktop.
Bash script for backing up web projects.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
printf "[BACKUP PROJECTS]\n\n" | |
temp_dir=$(mktemp -d) | |
package_name=backup_package | |
mkdir ~/$package_name | |
printf "COPYING TO TEMP DIR...\n\n" | |
cp -r $1 $temp_dir | |
cd $temp_dir | |
# Clean up Python, JS and PHP libs | |
printf "CLEANING UP...\n\n" | |
find . -name "site-packages" -type d -prune -exec rm -rf '{}' + | |
find . -name "node_modules" -type d -prune -exec rm -rf '{}' + | |
find . -name "vendor" -type d -prune -exec rm -rf '{}' + | |
printf "COMPRESSING...\n\n" | |
for f in $temp_dir/*; do | |
filename=$(basename $f) | |
printf "\t Compressing $filename\n" | |
tar czf ~/$package_name/$filename.tar.gz $filename | |
printf "\t Done $filename \n\n" | |
done | |
# Remove temp | |
printf "REMOVING TEMP DIR...\n\n" | |
yes | rm -R $temp_dir | |
printf "[TASK DONE!]\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment