Last active
July 3, 2018 18:11
-
-
Save LuisFcoOrtiz/4ba6a47630f74dbe6a3f60733510be95 to your computer and use it in GitHub Desktop.
(BASH)Copia de seguridad de una carpeta completa comprimiendo su tamaño | (BASH)Backup from a complete folder reducing his weight
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 | |
## make a backup from whole folder entry by argument## | |
## $1 only could be a folder or file ## | |
## For desscompress use tar -xvf file.tar.gz ## | |
actualDate=$(date +"%Y-%m-%d") | |
errorState=$? | |
folderPath="/home/manrique/BACKUPS" | |
tar -zcvf $folderPath/$1-$actualDate.tar.gz $1 | |
##Check errors | |
if [ $errorState -eq 0 ]; then | |
echo "------------------------------------------------------" | |
echo " Backup complete. in $folderPath" | |
echo "------------------------------------------------------" | |
## send system log to /var/log/syslog | |
echo "$actualDate Backup $1 file complete in $folderPath" >> /var/log/syslog | |
else | |
echo "Error succeded, see systemlog" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You must change the folderPath to your own backup folder path