Skip to main content

Home/ dfs201011/ Group items tagged 2082

Rss Feed Group items tagged

ivan chill

Reseller Backup Scripts? [Archive] - JaguarPC Community - Web Hosting, VPS Hosting, cPa... - 1 views

  • #!/bin/bash # Nightly backup system for home directories and MySQL # databases for websites managed by CPanel. # Author: Kieran O'Shea # Author's Website: www.kieranoshea.com # Support: kieran@kieranoshea.com # License: GPLv2 # USAGE: Place this file inside the directory you want to # put backups in, set it as a CRON job to run and collect # backups from the site(s) you define below at a preset # time each day, or run it manually everytime you want to # take a backup. You can place an unlimited number of sites # and databases to be backed up in the variables below so # long as you follow the convention. It doesn't even matter # if your different domains are hosted in different locations # so long as they are all managed by CPanel. # Prerequisites: # - Linux box with bash shell # - wget installed # Define all the sites you wish to backup in the array below # Domain name and tld only, eg. kieranoshea.com domain=( domain1.com domain2.com ) # Define all the usernames for the above sites in the array # below - keep order consistant! user=( user1 user2 ) # Define all the passwords for the above usernames in the # array below - keep order consistant! If you log on as # reseller or root you can enter the same password in # every array position, but none the less they must be filled. pass=( pass1 pass2 ) # Number of databases in each domain above - keep order # consistant. If you don't wish to backup any databases # for a particular domain, or don't have any for it, place # a 0 in it's position in the array. no_of_db=( 3 1 ) # Database names, exactly as they are in CPanel, in the order # that the domains appear. You may like to log into CPanel # manually and check your database names before filling this # variable in. Number of db names here must match the above # variables also! Eg. all dbs in domain 1 followed by all # dbs in domain 2 etc. You DO NOT need to enter any database # names below for a domain if you have placed a zero for it # in the array above databases=( domain1_datebase1 domain1_datebase2 domain1_datebase3 domain2_datebase1 ) # Thats all folks, save the file, CHMOD it to be executable # by the user who will run it, and you are all set. # Do not edit anything below this point! echo echo "-----------------------------------------------------------------" echo "Kieran's nightly backup system started" echo "-----------------------------------------------------------------" echo "" echo "-----------------------------------------------------------------" echo "Creating a directory in your backup path for tonights backup..." echo "-----------------------------------------------------------------" FOLDER="$(date +%d-%m-%Y)" mkdir $FOLDER cd $FOLDER echo "-------" echo "Done!" echo "-------" echo "" echo "-----------------------------------------------------------------" echo "Creating a directory for every domain to be backed up into..." echo "-----------------------------------------------------------------" count=${#domain } i=0 while [ "$i" -lt "$count" ] do mkdir ${domain[$i]} let "i = $i + 1" done echo "-------" echo "Done!" echo "-------" echo "" echo "-----------------------------------------------------------------" echo "Backing up MySQL databases..." echo "-----------------------------------------------------------------" overall_db_count=0 count=${#domain } i=0 while [ "$i" -lt "$count" ] do cd ${domain[$i]} mkdir databases cd databases start_point=$overall_db_count # start point for iterating over the array of db names let "end_point = $overall_db_count + ${no_of_db[$i]}" # end point to stop iterating (always the overall count!) n=$start_point while [ "$n" -lt "$end_point" ] do wget http://${user[$i]}:${pass[$i]}@www.${domain[$i]}:2082/getsqlbackup/${databases[$n]}.gz let "n = $n + 1" done let "overall_db_count = $overall_db_count + ${no_of_db[$i]}" # increase the overall count to keep a tally cd .. cd .. let "i = $i + 1" done echo "-------" echo "Done!" echo "-------" echo "" echo "-----------------------------------------------------------------" echo "Backing up home directories; this make take some time..." echo "-----------------------------------------------------------------" count=${#domain } i=0 while [ "$i" -lt "$count" ] do cd ${domain[$i]} wget http://${user[$i]}:${pass[$i]}@www.${domain[$i]}:2082/getbackup/backup-${domain[$i]}-$FOLDER.tar.gz cd .. let "i = $i + 1" done echo "-------" echo "Done!" echo "-------" echo "" echo "-----------------------------------------------------------------" echo "All backup tasks completed. Goodnight!" echo "-----------------------------------------------------------------"
  •  
    Cómo hacer el backup de un hosting mediante comandos cpanel
1 - 1 of 1
Showing 20 items per page