#!/bin/bashif ls /backup | grep $ (date +%f) &> /dev/nullthen echo "Today is already backup" exit 1else if ls / | grep backup &> /dev/null then if [ - f /backup ] then mv /backup /$ (date +%t) &> /dev/null echo "changename backup to $ (date +%t ) " mkdir /backup &> /dev/null cp -r /etc /backup/$ (Date +%F) echo "$ (date +%f) backup success" echo "$ (date +%f) backup success" | mail -s "$ (date +%f) backup success" root else if [ -d /backup ] then echo "Backup is a dirctory" cp -r /etc /backup/$ ( date +%f) echo "$ (date +%f) backup success " echo "$ (date +%F) backup success " | mail -s " $ (date +%f) backup success " Root fi fi else mkdir /backup &> / dev/null cp -r /etc /backup/$ (Date +%F) echo "$ (date +%f) backup success" echo "$ (date +%f) backup success" | mail -s "$ (date +%f) backup success " root fifi
If script instance-data backup