Though they are only tested on Ubuntu 14.04 LTS server edition 64bit
You do need to have touch installed for this to work!
Code: Select all
#!/bin/bash
#----------------------------------------------------
# a mysql database backup script for Darkstar Server.
# dsbackup.sh version 1, 2/29/2016
# Kosmos
#----------------------------------------------------
# This work is setup of GNUv3 Usage
#----------------------------------------------------
# (1) set up all the mysqldump variables
FILE=dsbackup.sql.`date +"%Y%m%d"`
DBSERVER=127.0.0.1
DATABASE=dspdb
USER=darkstar
PASS=yourpassword
# (2) in case you run this more than once a day, remove the previous version of the file
unalias rm 2> /dev/null
rm ${FILE} 2> /dev/null
rm ${FILE}.gz 2> /dev/null
# (3) make files if not made
mkdir backup
touch backup/accounts.sql
touch backup/char_effects.sql
touch backup/char_equip.sql
touch backup/char_exp.sql
touch backup/char_inventory.sql
touch backup/char_jobs.sql
touch backup/char_look.sql
touch backup/char_merit.sql
touch backup/char_pet_name.sql
touch backup/char_points.sql
touch backup/char_profile.sql
touch backup/char_skills.sql
touch backup/char_stats.sql
touch backup/char_storage.sql
touch backup/char_spells.sql
touch backup/char_blacklist.sql
touch backup/char_vars.sql
touch backup/char_style.sql
touch backup/char_weapon_skill_points.sql
touch backup/chars.sql
touch backup/delivery_box.sql
touch backup/linkshells.sql
touch backup/server_variables.sql
touch backup/zone_settings.sql
touch backup/auction_house.sql
touch backup/char_pet.sql
# (4) do the mysql database backup (dump)
# use this command for a database server on a separate host:
#mysqldump --opt --protocol=TCP --user=${USER} --password=${PASS} --host=${DBSERVER} ${DATABASE} > ${FILE}
# use this command for a database server on localhost. add other options if need be.
echo "Starting Backup"
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} accounts > backup/accounts.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} char_effects > backup/char_effects.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} char_equip > backup/char_equip.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} char_exp > backup/char_exp.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} char_inventory > backup/char_inventory.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} char_jobs > backup/char_jobs.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} char_look > backup/char_look.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} char_merit > backup/char_merit.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} char_pet_name > backup/char_pet_name.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} char_points > backup/char_points.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} char_profile > backup/char_profile.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} char_skills > backup/char_skills.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} char_stats > backup/char_stats.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} char_storage > backup/char_storage.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} char_spells > backup/char_spells.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} char_blacklist > backup/char_blacklist.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} char_vars > backup/char_vars.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} char_style > backup/char_style.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} char_pet > backup/char_pet.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} char_weapon_skill_points > backup/char_weapon_skill_points.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} chars > backup/chars.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} delivery_box > backup/delivery_box.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} linkshells > backup/linkshells.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} server_variables > backup/server_variables.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} zone_settings > backup/zone_settings.sql
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} auction_house > backup/auction_house.sql
echo "Backup of DATABASE done"
# (5) tar the mysql database dump
echo "Starting to Compress Files"
tar zcvf backup.`date +"%Y%m%d"`.tar.gz backup/
echo "Compression done"
# (6) show the result
ls -l backup.`date +"%Y%m%d"`.tar.gz
Code: Select all
#!/bin/bash
#----------------------------------------------------
# a mysql database import script for Darkstar Server.
# dsimport.sh version 1, 2/29/2016
# Kosmos
#----------------------------------------------------
# This work is setup of GNUv3 Usage
#----------------------------------------------------
# (1) set up all the mysql variables
#FILE=dsbackup.sql.`date +"%Y%m%d"`
DBSERVER=127.0.0.1
DATABASE=dspdb
USER=darkstar
PASS=yourpassword
# (2) Decompress the file
echo "Starting Decompression"
tar -xzf backup.*.tar.gz
echo "Decompression Done"
# (3) Import The tables
echo "Starting to Import Tables"
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/accounts.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/char_effects.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/char_equip.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/char_exp.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/char_inventory.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/char_jobs.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/char_look.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/char_merit.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/char_pet_name.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/char_points.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/char_profile.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/char_skills.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/char_stats.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/char_storage.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/char_spells.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/char_blacklist.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/char_vars.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/char_style.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/char_pet.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/char_weapon_skill_points.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/chars.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/delivery_box.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/linkshells.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/server_variables.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/zone_settings.sql
mysql --user=${USER} --password=${PASS} ${DATABASE} < backup/auction_house.sql
# (5) show the user the result
echo "Script done Tables Imported"