Welcome to Onforum.net - Web and gaming resource community

Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for?

Quests /Python Script automatic backup of server and database files in python

Vanilla

Elite
Elite
Credits
1,136
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
 

Similar threads


About us

OnForum.net is a resource community where aspiring webmasters and designers can share content and receive support for a wide variety of software platforms. We are working every day to make sure our community is one of the best.

None of the files are hosted on this site.

PARTNERS

Follow us

We recommend

Doza de Blog
Top

Dear User!

We found that you are blocking the display of ads on our site.

Please add it to the exception list or disable AdBlock.

The advertises that you'll see aren't intrusive they just help us to keep the community alive

If you don't want to see those ads just buy an upgrade.

Thank you for understanding!