Rabu, 26 November 2014

Script Backup On proxmox cluster

#!/bin/bash
# declare destination directory
folder=/root/bekup-etc
folder2=/root/bekup-var
folder3=/root/bekup-ssh
# memastikan destination directory sdh exist
if [ ! -d $folder ]
then
mkdir -p $folder
fi
# memastikan destination directory sdh exist
if [ ! -d $folder2 ]
then
mkdir -p $folder2
fi
# memastikan destination directory sdh exist
if [ ! -d $folder3 ]
then
mkdir -p $folder3
fi
# backup all configuration from ./etc.
tar -cvzf $folder/etc-`hostname`.`dnsdomainname`-`date | awk '{print $2$3$1$4$5$6$7}'`.tar.gz /etc
# backup .ssh
tar -cvzf $folder3/ssh-`hostname`.`dnsdomainname`-`date | awk '{print $3$2$6}'`.tar.gz /root/.ssh
#backup var/lib/pve
tar -cvzf $folder/etc-`hostname`.`dnsdomainname`-`date | awk '{print $3$2$6}'`.tar.gz /var/lib/pve-cluster

# menghapus file ketika isi folder sudah 30 lebih
find /root/bekup/*.gz -mtime +30 -exec rm -f {} \
atau
find /root/bekup/*.gz -mtime +30 -exec rm -f -- {} \+

jangan lupa chmod +x file sh nya

Tidak ada komentar:

Posting Komentar

have a question, just spill it :D

Related Posts Plugin for WordPress, Blogger...