Actualiser Backup_OpenStack_Vms_And_Volumes.sh
This commit is contained in:
		
							parent
							
								
									64836447f2
								
							
						
					
					
						commit
						dfd649678c
					
				
					 1 changed files with 19 additions and 16 deletions
				
			
		| 
						 | 
				
			
			@ -1,20 +1,21 @@
 | 
			
		|||
#!/usr/bin/env bash
 | 
			
		||||
 | 
			
		||||
#source openrc.sh
 | 
			
		||||
#export OS_AUTH_TYPE=v3applicationcredential
 | 
			
		||||
#export OS_AUTH_URL=https://auth.cloud.ovh.net/
 | 
			
		||||
#export OS_IDENTITY_API_VERSION=3
 | 
			
		||||
#export OS_INTERFACE=public
 | 
			
		||||
#export OS_REGION_NAME="GRA11"
 | 
			
		||||
#export OS_APPLICATION_CREDENTIAL_ID=
 | 
			
		||||
#export OS_APPLICATION_CREDENTIAL_SECRET=
 | 
			
		||||
export OS_AUTH_TYPE=v3applicationcredential
 | 
			
		||||
export OS_AUTH_URL=https://auth.cloud.ovh.net/
 | 
			
		||||
export OS_IDENTITY_API_VERSION=3
 | 
			
		||||
export OS_INTERFACE=public
 | 
			
		||||
export OS_REGION_NAME="GRA11"
 | 
			
		||||
export OS_APPLICATION_CREDENTIAL_ID=
 | 
			
		||||
export OS_APPLICATION_CREDENTIAL_SECRET=
 | 
			
		||||
export PROJECT_ID=
 | 
			
		||||
 | 
			
		||||
#Daily Retention (Nb of months)
 | 
			
		||||
export DAILY_RETENTION=7
 | 
			
		||||
export DAILY_RETENTION=20
 | 
			
		||||
 | 
			
		||||
#Monthly Retention (Nb of months)
 | 
			
		||||
# 0 =  disable monthly backup
 | 
			
		||||
export MONTHLY_RETENTION=0
 | 
			
		||||
export MONTHLY_RETENTION=12
 | 
			
		||||
# DAY OF MOUNTH TO EXECUTE MONTHLY BACKUP
 | 
			
		||||
# 01 ... 30 31
 | 
			
		||||
export DAY_MONTHLY_BACKUP=01
 | 
			
		||||
| 
						 | 
				
			
			@ -29,6 +30,9 @@ export DAY_OF_YEARLY_BACKUP=01
 | 
			
		|||
# 01:january... 12:December
 | 
			
		||||
export MONTH_OF_YEARLY_BACKUP=01
 | 
			
		||||
 | 
			
		||||
# Number of backup instances to keep
 | 
			
		||||
export MAX_KEEP_BACKUP_INSTANCES=100
 | 
			
		||||
 | 
			
		||||
#Set TimeZone
 | 
			
		||||
export TZ=Europe/Paris
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -166,7 +170,7 @@ function backup(){
 | 
			
		|||
 | 
			
		||||
        _info_action " ------> [Instance : ${SERVER}] ---> Launching the Snapshot of the instance ${SERVER} to ${BCK_SERVER}"
 | 
			
		||||
        BCK_INSTANCES_LIST+=(${BCK_SERVER})
 | 
			
		||||
        ${OPENSTACK} server backup create --name ${BCK_SERVER} ${SERVER}
 | 
			
		||||
        ${OPENSTACK} server backup create --rotate ${MAX_KEEP_BACKUP_INSTANCES} --name ${BCK_SERVER} ${SERVER}
 | 
			
		||||
 | 
			
		||||
        _info_blue " ------> [Instance : ${SERVER}] === === End of the backup === ==="
 | 
			
		||||
    done
 | 
			
		||||
| 
						 | 
				
			
			@ -179,7 +183,7 @@ function check_backup(){
 | 
			
		|||
        _info "================================================================================"
 | 
			
		||||
 | 
			
		||||
        MAXIMUM_TIMESTAMP=`date -d '+'${CHECK_BACKUP_DELAY}' seconds' '+%s'`
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        echo ""
 | 
			
		||||
        _info " => Checking the backup of volumes"
 | 
			
		||||
        for BCK_VOLUME in "${BCK_VOLUMES_LIST[@]}"
 | 
			
		||||
| 
						 | 
				
			
			@ -228,7 +232,7 @@ function manage_retention(){
 | 
			
		|||
    _info "================================================================================"
 | 
			
		||||
    _info " - Manage Backup Retention"
 | 
			
		||||
    _info "================================================================================"
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    echo ""
 | 
			
		||||
    _info " ====> Manage Retention for Backup Volumes <===="
 | 
			
		||||
    ALL_BCK_VOLUMES=$(${OPENSTACK} volume backup list -f json)
 | 
			
		||||
| 
						 | 
				
			
			@ -349,7 +353,7 @@ function manage_retention(){
 | 
			
		|||
function job_details(){
 | 
			
		||||
    _info_blue "#######################################################################################"
 | 
			
		||||
    _info_blue "Starting Backup Job "
 | 
			
		||||
    PJT_DESC=$(${OPENSTACK} project show ${OS_TENANT_ID} -f json | ${JQ} -r '.description')
 | 
			
		||||
    PJT_DESC=$(${OPENSTACK} project show ${PROJECT_ID} -f json | ${JQ} -r '.description')
 | 
			
		||||
    _info_blue " ---> Project Description : ${PJT_DESC}"
 | 
			
		||||
    _info_blue " ---> Region : ${OS_REGION_NAME}"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -369,7 +373,7 @@ function job_details(){
 | 
			
		|||
    else
 | 
			
		||||
        _info_blue "       --> Monthly Retention : Disabled"
 | 
			
		||||
    fi
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    if [ "${YEARLY_RETENTION}" != "0" ]; then
 | 
			
		||||
        _info_blue "       --> Yearly Retention : ${YEARLY_RETENTION} Year(s)"
 | 
			
		||||
    else
 | 
			
		||||
| 
						 | 
				
			
			@ -402,7 +406,6 @@ function _warning(){
 | 
			
		|||
 | 
			
		||||
function main() {
 | 
			
		||||
    job_details
 | 
			
		||||
    exit
 | 
			
		||||
    check_prerequistes
 | 
			
		||||
    backup
 | 
			
		||||
    check_backup
 | 
			
		||||
| 
						 | 
				
			
			@ -411,4 +414,4 @@ function main() {
 | 
			
		|||
 | 
			
		||||
main "$@"
 | 
			
		||||
 | 
			
		||||
exit ${EXIT}
 | 
			
		||||
exit ${EXIT}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue