حذف الباك اب التى ليس لها حسابات

فموضوع فى منتدى مطور

كان فى موضوع بيتكلم عن ال for

وكان سؤال كارم كالتالى :

لديك الكثير من المواقع منها من نقل خارج سيرفرك ومازال له بك اب عندك كيف تنضف البك اب من المواقع الى غير موجودة لديك بالنظام الان .

وقمت بعمل سكربت بسيط يقوم بهذه العملية

#!/bin/bash
# Auther : Eng.M7MoD

ls /backup/cpbackup/daily/ >/tmp/backuplist.txt

ls /var/cpanel/users >/tmp/userlist.txt

awk -F”.tar.gz” ‘{ print $1 }’ /tmp/backuplist.txt >/tmp/f1.txt

diff -w -B /tmp/userlist.txt /tmp/f1.txt | awk ‘{print $2}’ >/tmp/last.txt

cat /tmp/last.txt

echo -n “Are you sure that is backup you need to delete ?(yes/no)”;read answer

if [ $answer = yes ];then

for i in `cat /tmp/last.txt`

do

rm -rf $i.tar.gz

done

echo “all backup that doesn’t have account was deleted”

else

echo “ok i’ll skip this fot you at this time”

fi

rm -rf /tmp/*.txt

No Tags

2 تعليقات to 'حذف الباك اب التى ليس لها حسابات'

Subscribe to comments with خلاصة آخر التدوينات RSS or TrackBack to 'حذف الباك اب التى ليس لها حسابات'.

  1. EGYG33K قال,

    nice shell script ya 7oda you remind me with the old times ya man

  2. the old time still there ya 3amor

    thank you ya man

:: Trackbacks/Pingbacks ::

No Trackbacks/Pingbacks

اضف تعليق على التدوينة