Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section General Discussion
  • Search

Script to backup the db for each site

General questions about VestaCP
Post Reply
  • Print view
Advanced search
7 posts • Page 1 of 1
augustocarmo
Posts: 10
Joined: Thu Aug 23, 2018 8:58 pm

Os: CentOS 6x
Web: nginx + php-fpm
Script to backup the db for each site
  • Quote

Post by augustocarmo » Sat Aug 25, 2018 1:31 pm

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.
Top

ScIT
Support team
Posts: 617
Joined: Mon Feb 23, 2015 4:13 pm

Os: Ubuntu 17x
Web: apache + nginx
Re: Script to backup the db for each site
  • Quote

Post by ScIT » Sat Aug 25, 2018 3:41 pm

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.
Top

augustocarmo
Posts: 10
Joined: Thu Aug 23, 2018 8:58 pm

Os: CentOS 6x
Web: nginx + php-fpm
Re: Script to backup the db for each site
  • Quote

Post by augustocarmo » Sun Aug 26, 2018 3:05 am

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
Top

augustocarmo
Posts: 10
Joined: Thu Aug 23, 2018 8:58 pm

Os: CentOS 6x
Web: nginx + php-fpm
Re: Script to backup the db for each site
  • Quote

Post by augustocarmo » Mon Aug 27, 2018 12:34 am

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.
Top

ScIT
Support team
Posts: 617
Joined: Mon Feb 23, 2015 4:13 pm

Os: Ubuntu 17x
Web: apache + nginx
Re: Script to backup the db for each site
  • Quote

Post by ScIT » Mon Aug 27, 2018 5:23 am

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.
Top

augustocarmo
Posts: 10
Joined: Thu Aug 23, 2018 8:58 pm

Os: CentOS 6x
Web: nginx + php-fpm
Re: Script to backup the db for each site
  • Quote

Post by augustocarmo » Mon Aug 27, 2018 1:27 pm

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.
Last edited by augustocarmo on Mon Sep 10, 2018 3:46 pm, edited 1 time in total.
Top

skamasle
Collaborator
Posts: 592
Joined: Mon Feb 29, 2016 6:36 pm

Re: Script to backup the db for each site
  • Quote

Post by skamasle » Fri Aug 31, 2018 9:40 am

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
Top


Post Reply
  • Print view

7 posts • Page 1 of 1

Return to “General Discussion”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

cron

Login  •  Register

I forgot my password