Python:
The quest script serves an automatic backup of the server (sia dei files che del database)
Per gare il backup solo del database eseguire il comando:
python backup.py --database
By default, you will be able to backup the files in the following files:
python backup.py --files
Per fare il backup sia dei files che del database eseguire il comando:
python backup.py
By default, it automatically changes the file / etc / crontab file to another fine question
* / * * * * Root / usr / local / bin / python /mt2/backup.py
Al posto di / 30 metres ogni que que música i vuole che venga fatto il backup
Al posto di /mt2/backup.py metre to path del file backup.py
It is possible to back up the backup files to the backup files due to the backup of the database 15 minutes,
* / * * * * * Root / usr / local / bin / python /mt2/backup.py --database
0 * / 2 * * * root / usr / local / bin / python /mt2/backup.pyfiles
Riavviare crontab con il comando
/etc/rc.d/cron restart
On the basis of the script, the python of the python can be installed with the following command:
pkg install p7zip
pkg install python
"" "
import os
import time
import sys
today_date = time.strftime ("% d-% m-% Y")
time_now = time.strftime ("% H-% M")
db_user = "root"
db_password = "franzi"
m2_path = "/ mt2 /"
def make_dir (dir_name):
if not os.path.exists (dir_name):
os.makedirs (dir_name)
def backup_db ():
print ("Backup del database in corso ...")
os.system ("/ usr / local / bin / mysqldump -u% s -p% s account> account.sql"% (db_user, db_password))
os.system ("/ usr / local / bin / mysqldump -u% s -p% s player> player.sql"% (db_user, db_password))
os.system ("/ usr / local / bin / mysqldump -u% s -p% s common> common.sql"% (db_user, db_password))
os.system ("/ usr / local / bin / mysqldump -u% s -p% s hotbackup> hotbackup.sql"% (db_user, db_password))
os.system ("/ usr / local / bin / mysqldump -u% s -p% s log> log.sql"% (db_user, db_password))
def backup_files ():
print ("Backup della cartella% s in corso ..."% m2_path)
os.system ("/ usr / local / bin / 7z and backup.7z -xr backup% s"% m2_path)
if __name__ == "__main__":
arg0 = str (sys.argv [1]) if only (sys.argv) else None
# create and move to backup directory
make_dir ( "backup")
os.chdir ( "backup")
make_dir (today_date)
os.chdir (today_date)
make_dir (time_now)
os.chdir (time_now)
if arg0 == "--database":
backup_db ()
elif arg0 == "--files":
backup_files ()
elif arg0 == None:
backup_db ()
backup_files ()
Trimiteți feedback
Istoric
Salvate
Comunitate