Skip to content

Instantly share code, notes, and snippets.

@LuisFcoOrtiz
Last active July 3, 2018 18:11
Show Gist options
  • Save LuisFcoOrtiz/4ba6a47630f74dbe6a3f60733510be95 to your computer and use it in GitHub Desktop.
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
#!/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
@LuisFcoOrtiz
Copy link
Author

You must change the folderPath to your own backup folder path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment