#!/bin/bash
for file in $@
do
Inode=$(stat $file | grep -- 'Inode:' | sed -e's/.*Inode: \([0-9]*\).*/\1/')
Links=$(stat $file | grep -- 'Links:' | sed -e's/.*Links: \([0-9]*\).*/\1/')
if test $Links -ge 2
then
find -inum $Inode | xargs shred -u -n 30 -z
else
stat $file | grep -- 'File:' | sed -e's/[^‘]*‘\([^ ]*\)’[^‘]*/\1 /g' | xargs shred -u -n 30 -z
fi
done
TIME=`date +%Y-%m-%d-%H-%M-%S`
SERVER_NAME="servername"
MYSQL_FILE=/tmp/$SERVER_NAME-mysql.$TIME.sql.gz
FS_FILE=/tmp/$SERVER_NAME-fs.$TIME.tar.gz
# Archiving databases
mysqldump -u *** --password=*** backup_db | gzip > $MYSQL_FILE
if [ -f $MYSQL_FILE ]; then
echo $TIME" db dump created"
# Uploading to the cloud
curl --user ***@yandex.ru:***-T "{$MYSQL_FILE}" https://webdav.yandex.ru/backup/database/
#Delete archve
rm $MYSQL_FILE