Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- set -e
- # Configure these as needed
- DIRECTORY="/opt/gst-deploye/"
- ARCHIVE_PATH="/home/usradmin/archived.gst.rollout/gst_fullbackup/"
- DATE=$(date +"%d.%m.%Y_%H%M")
- ARCHIVE_FILE="$(hostname)_$DATE.tgz"
- HOST='192.168.6.73'
- USER='admin'
- PASS='admin'
- TARGETFOLDER='/gst/gst_fullbackup/'
- SOURCEFOLDER='/home/usradmin/archived.gst.rollout/gst_fullbackup/'
- #'/gst/gst_folderbackup/'
- # Create the tarball
- archive_directory () {
- tar czf $ARCHIVE_PATH/$ARCHIVE_FILE $DIRECTORY &> /dev/null
- }
- # Delete files older than 7 days
- cleanup_old_files() {
- find $ARCHIVE_PATH -mtime +4 -exec rm {} \;
- }
- upload_backup_fullbackup_files(){
- lftp -f"
- open $HOST
- user $USER $PASS
- lcd $SOURCEFOLDER
- # mirror - mirror folder contents --reverse is to put file -n put files which are new --verbose print details source folder target folder
- mirror --reverse --continue -n --verbose $SOURCEFOLDER $TARGETFOLDER
- bye
- "
- }
- # Do the stuff with the things
- archive_directory
- cleanup_old_files
- upload_backup_fullbackup_files
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement