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

customize backup script

General questions about VestaCP
Post Reply
  • Print view
Advanced search
15 posts
  • 1
  • 2
  • Next
mehargags
Support team
Posts: 1096
Joined: Sat Sep 06, 2014 9:58 pm
Contact:
Contact mehargags
Website Skype

Os: Debian 8x
Web: apache + nginx
customize backup script
  • Quote

Post by mehargags » Sun Aug 07, 2016 2:57 pm

Hi,
Can anyone help me customize or create a new Backup script that only:

1. Backs up domain/public_html/ from $user/web directory recursively
2. The Databases

and create a tarball of it

Don't need any user directories or vesta Specific Configuration backup.
Top

skurudo
VestaCP Team
Posts: 8099
Joined: Fri Dec 26, 2014 2:23 pm
Contact:
Contact skurudo
Website Facebook Google+ Skype
Twitter

Re: customize backup script
  • Quote

Post by skurudo » Thu Aug 11, 2016 2:59 pm

mehargags wrote: Don't need any user directories or vesta Specific Configuration backup.
So much wasted space?
Remember, about restore too... if custome backup, then you need custom restore ;-(
Top

mehargags
Support team
Posts: 1096
Joined: Sat Sep 06, 2014 9:58 pm
Contact:
Contact mehargags
Website Skype

Os: Debian 8x
Web: apache + nginx
Re: customize backup script
  • Quote

Post by mehargags » Thu Aug 11, 2016 4:25 pm

skurudo wrote:
mehargags wrote: Don't need any user directories or vesta Specific Configuration backup.
So much wasted space?
Remember, about restore too... if custome backup, then you need custom restore ;-(
Yes no problems... I can always restore manually from the tarballs... vestaCP doesn't restore backups well for me either way.

All I just need is site files + DB only
Top

coolman
Posts: 11
Joined: Thu Nov 27, 2014 3:19 pm

Re: customize backup script
  • Quote

Post by coolman » Mon Aug 22, 2016 8:39 am

Any progress on this case? I need to customize backup too.

Current backup script does not follow symbolic links, so my backups are not complete. Here is my file structure:

/home/admin/web/site1 - has only several files and a symbolic link
/home/admin/web/site1/public_html --> /home/admin/web/template1
/home/admin/web/site2 - has only several files and a symbolic link
/home/admin/web/site2/public_html --> /home/admin/web/template1
/home/admin/web/site3 - has only several files and a symbolic link
/home/admin/web/site3/public_html --> /home/admin/web/template1
/home/admin/web/site4 - has only several files and a symbolic link
/home/admin/web/site4/public_html --> /home/admin/web/template2
/home/admin/web/site4 - has only several files and a symbolic link
/home/admin/web/site4/public_html --> /home/admin/web/template2
/home/admin/web/template1 - has a lot of files
/home/admin/web/template2 - has a lot of files

Current backup script only backs up /home/admin/web/site* directories and does not backup /home/admin/web/template* directories. How can I make it backup /home/admin/web/template* directories too?

Thanks
Top

mehargags
Support team
Posts: 1096
Joined: Sat Sep 06, 2014 9:58 pm
Contact:
Contact mehargags
Website Skype

Os: Debian 8x
Web: apache + nginx
Re: customize backup script
  • Quote

Post by mehargags » Mon Aug 22, 2016 11:12 am

I'm getting it made myself with the help of another forum member dpeca, lets see if it goes well!
Top

coolman
Posts: 11
Joined: Thu Nov 27, 2014 3:19 pm

Re: customize backup script
  • Quote

Post by coolman » Mon Aug 22, 2016 5:49 pm

I found a workaround. I moved template files to /home/admin/template from /home/admin/web/template. Now template files backed up.
Top

dpeca
VestaCP Team
Posts: 473
Joined: Wed Nov 25, 2015 7:30 pm

Re: customize backup script
  • Quote

Post by dpeca » Wed Aug 24, 2016 10:19 am

* UPDATED to v0.2 *

This will backup files from ALL websites in VestaCP (each of them as separated archive), and put tar file in /backup/manual/ folder as domain.com-YYYY-MM-DD.tar(.gz)

Code: Select all

#!/bin/bash

# Options:

backup_folder=/backup/manual

compress=0

exclude="--exclude='*/tmp/*' --exclude='*/temp/*' --exclude='*/log/*' --exclude='*/logs/*' --exclude='*/session/*' --exclude='*/sessions/*' --exclude='*/cache/*' --exclude='*/caches/*'"

use_absolute_full_path=1

backup_public_html=1
backup_public_shtml=0

################################################################################################################
# begin of script
#
# *** Script for backuping all VestaCP sites (only files) ***
#
# Created by dpeca (Predrag Damnjanovic - https://forum.vestacp.com/memberlist.php?mode=viewprofile&u=8116 )
# version: 0.2
#

if [ ! -d "$backup_folder" ]; then
	eval "mkdir $backup_folder"
fi

taroptions="cfP"
extension=tar
date=$(date +"%Y-%m-%d")

if [[ $compress -eq 1 ]]; then
	taroptions="czfP"
	extension=tar.gz
fi

function make_tar {
	folder=$1
	site=$2
	shtml=$3
	if [[ $shtml -eq 1 ]]; then
		site="$site.shtml"
	fi
	
	if [[ $use_absolute_full_path -eq 1 ]]; then
		command="tar $taroptions $backup_folder/$site-$date.$extension -C / $folder $exclude"
	else
		cd $folder
		command="tar $taroptions $backup_folder/$site-$date.$extension . $exclude"
	fi
	# echo $command
	eval $command
}


for name in /home/*
do
    if [ -d "$name" ]; then
		#echo $name/web
		if [ -d "$name/web" ]; then

			for name2 in $name/web
			do
				if [ -d "$name2" ]; then
					#echo $name2
					for name3 in $name2/*
					do
						if [[ $backup_public_html -eq 1 ]]; then
							folder=$name3/public_html
							site=$(basename $name3)
							if [ -d "$folder" ]; then
								make_tar $folder $site 0
							fi
						fi
						if [[ $backup_public_shtml -eq 1 ]]; then
							folder=$name3/public_shtml
							site=$(basename $name3)
							if [ -d "$folder" ]; then
								make_tar $folder $site 1
							fi
						fi
					done
				fi
			done
		fi
    fi
done
Last edited by dpeca on Thu Aug 25, 2016 12:44 am, edited 4 times in total.
Top

mehargags
Support team
Posts: 1096
Joined: Sat Sep 06, 2014 9:58 pm
Contact:
Contact mehargags
Website Skype

Os: Debian 8x
Web: apache + nginx
Re: customize backup script
  • Quote

Post by mehargags » Wed Aug 24, 2016 11:33 am

Works like a charm!!
thanks a ton dpeca
Top

skurudo
VestaCP Team
Posts: 8099
Joined: Fri Dec 26, 2014 2:23 pm
Contact:
Contact skurudo
Website Facebook Google+ Skype
Twitter

Re: customize backup script
  • Quote

Post by skurudo » Wed Aug 24, 2016 12:19 pm

Added as Idea -> https://bugs.vestacp.com/issues/364
I like this too ^_^
Top

mehargags
Support team
Posts: 1096
Joined: Sat Sep 06, 2014 9:58 pm
Contact:
Contact mehargags
Website Skype

Os: Debian 8x
Web: apache + nginx
Re: customize backup script
  • Quote

Post by mehargags » Wed Aug 24, 2016 6:46 pm

skurudo wrote:Added as Idea -> https://bugs.vestacp.com/issues/364
I like this too ^_^
Thanks Skurudo for liking this and putting it as feature request... Sometimes all you need is a lean-mean Website dump only to quickly migrate to a new server or give the client his/her data. Will save alot of time!
Top


Post Reply
  • Print view

15 posts
  • 1
  • 2
  • Next

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
 

 

Login  •  Register

I forgot my password