sh 备份bash脚本

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 备份bash脚本相关的知识,希望对你有一定的参考价值。

#!/bin/bash

service=*REPLACE WITH SERVICE*
DATE=`date +%m-%y`
dir=`pwd`
if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0)); then
	echo "$service is running, terminating..."
	killall $service
else
	echo "$service is not running..."
fi
echo "starting backup..."
tar -pzcf backup_$DATE.tar.gz /*REPLACE WITH DIR*/
echo "backup done, checking integrety"
tar -tvf $dir/backup_$DATE.tar.gz
echo "All done. please review integrety output to make sure everything went smoothly"
#!/bin/bash
# This script will stop SecurityCenter
# create a TAR ball of the /opt/sc dir
# Then start SC again.
service=SecurityCenter
 
if ($(service $service status | grep -v grep | grep running | wc -l) >0 ); then
  echo "$service is running, stopping it"
  service $service stop
  service $service status | grep Active
else
  echo "$service is not running, continuing."
fi
echo "starting backup..."
tar -pzcf sc_backup.tar.gz /opt/sc
echo "Backup finished, starting $service"

service $service start
service $service status | grep Active

以上是关于sh 备份bash脚本的主要内容,如果未能解决你的问题,请参考以下文章

sh bash备份轮换脚本

sh Bash脚本备份所有MySQL数据库

sh 用于将所有docker镜像备份到文件的bash脚本

sh bash脚本备份您的mongodb数据并将存档存储到AWS S3。

shell脚本定时备份日志===logBackup.sh

数据库备份脚本.sh