Page 1 of 1

Script to backup the db for each site

Posted: Sat Aug 25, 2018 1:31 pm
by augustocarmo
Hello, I'm taking another backup strategy for my VPS and now I'm trying to backup up only the db for each site and put in the folder of each one.

How can I accomplish that in the most automated way?

Thanks.

Re: Script to backup the db for each site

Posted: Sat Aug 25, 2018 3:41 pm
by ScIT
Hmm, you can use mysqldump and gzip, but why not use the integrated way for backup? Ypu can alsp check the v-backup-user file tp understand, how vesta is doing that job.

Re: Script to backup the db for each site

Posted: Sun Aug 26, 2018 3:05 am
by augustocarmo
I'm using restic to make incremental backups, is faster and use less bandwidth.

Will take a look in the script and try to find something.

Thanks

Re: Script to backup the db for each site

Posted: Mon Aug 27, 2018 12:34 am
by augustocarmo
I think that's ie beyond my understanding I'm don't enough knowledge of shell script to understand modify this script to do what I want.

Re: Script to backup the db for each site

Posted: Mon Aug 27, 2018 5:23 am
by ScIT
So I would think it is the savest way for you to use the internal backup engine - so you can be sure that the backup is working properly.

Re: Script to backup the db for each site

Posted: Mon Aug 27, 2018 1:27 pm
by augustocarmo
I'm using the internal backup too, but each backup has 2GB, using restic I can make a new snapshot using just the changed files, is more efficient.

Re: Script to backup the db for each site

Posted: Fri Aug 31, 2018 9:40 am
by skamasle
You can make easy script to backup all dabase per user not is to hard

You can take part of code from here: https://github.com/Skamasle/Incremental ... -backup.sh

You just need modify two functions:


This get user

Code: Select all

sk_check_user () {
sk_user=$1
if v-list-users plain | awk '{ print  $1 }' |grep -wc $sk_user ;then
	sk_back $sk_user
fi
}

This make a backup

Code: Select all

function backup_mysql () {
sk_user=$1
cd /tmp/sk_backup/
mkdir DataBases
# This restore all and then transfer not good for big databases
for db in $(v-list-databases $sk_user plain | awk '{ print  $1 }')
do
	mysqldump $db > DataBases/$db.sql
	gzip DataBases/$db.sql
done
	sk_sync DataBases
	rm -f DataBases/*.sql.gz
##
## Less space used, restore and transfer DBs one by one 
# Need code this with modification of sk_sync() - isnt urgent
}
The code is there just modify to aply it for your scripts