Druzai / Bot_Mc_discord

Discord bot to manage Minecraft server(s)
MIT License
3 stars 1 forks source link

Backup command #20

Closed MaxBQb closed 3 years ago

MaxBQb commented 3 years ago

%backup on | off | force | info | count | restore | period info is default

%backup on | off Toggles autobackup

%backup period <minutes> Set periof of automatic backups

%backup force <reason> Make backup of currently selected world

%backup count [count] If no count presented prints current maximum count of backups for selected world else max count set to this number support infinity value

%backup restore <date time> Restore current world with selected backup

%backup info [all] by default Show current auto-backup state Max backup count and latest backup info

output:

Automatic backup: off | on
Last backup: date time
Reason: Automatic backup | Custom text
Initiator: Mention

Example (auto)

Automatic backup: on
Last backup: 12.12.2012 22:22:08
Reason: Automatic backup

Example (caused by user)

Automatic backup: on
Last backup: 21.02.2021 16:04:01
Reason: We'll burn this world to ash
Initiator: ShadowMaster

%backup info all Prints info about all backups available:

1. Date: 21.02.2021 16:04:01
    Reason: We'll burn this world to ash
    Initiator: ShadowMaster

2. Date: 21.02.2021 16:14:01
    Reason: Automatic backup

Separate servers have separate backup

MaxBQb commented 3 years ago

Backup&restore https://github.com/Druzai/Bot_Mc_discord/issues/21#issue-954045333

MaxBQb commented 3 years ago

%restore as alias to %backup restore Also %backup size [max_size in MB] %backup size => current size limitation %backup size 10 => only 10 MB allowed If size not set, it's equals to amount of free space available

MaxBQb commented 3 years ago

Config option to select path to backups (Never allow someone to explore your filesystem) Maybe, size/count limitations also should be set via config? To avoid spaming backups leading to leack of free space Also maybe there should be some limitations in frequency of force backuping, to protect server disk from mass-overwrite

Druzai commented 3 years ago

@MaxBQb I think it would be useful to let members decide what type of compression to use for archiving zip-file, like: store, deflated, bzip2, lzma. And add subcommand %backup compression [algorithm] or %backup comp [algorithm] What do you think?

%backup period <minutes>

About this, I know good parser that can parse to datetime object. Maybe you don't have to limit this command only to minutes?

Maybe, size/count limitations also should be set via config?

In config will be name of default folder that will store all backups and size limit and backups max limit for each server For this name of default folder, it will be folder in server root dir

For now I think of 3 settings for backups in config, but you can suggest another settings :)

MaxBQb commented 3 years ago

About compression: When you don't know what kind of file you'll compress then it is a good idea to allow PRO users to choose most comprehensive algorithm (IMHO, auto detection is the better option), BUT: you DO know the types of files... because you create backups of server world, which always have same inner structure, so I think, that you should compare all this methods and just choose proper algorithm by your own. Anyway if you can't simply choose one, then you should add description for each method, to let user know, how to choose one, in terms of fast compression and smaller size.

You can use parser to get the time, also check how discord.py handles datetime/timedelta by it's own, and never forget to use parses in command type hints (it's better then stupid str everywhere) Also give me a link to this parser, I'll want to use it later :)

Druzai commented 3 years ago

About compression:

I think yes, I'll just write all the pros and cons of the algorithms/methods, users will choose a maximum of one or two times.

About parser: https://github.com/scrapinghub/dateparser. The result is datetime object, though. But it's interesting to experiment with it. :) Usage: (datetime.datetime.now() - dateparser.parse("5 hours")).seconds + 1 equals 18000

Druzai commented 3 years ago

%backup size => current size limitation %backup size 10 => only 10 MB allowed

Maybe it's not good to let server members change this value?

MaxBQb commented 3 years ago

Maybe

Druzai commented 3 years ago

Also maybe there should be some limitations in frequency of force backuping, to protect server disk from mass-overwrite

How much seconds must be between intervals? 1 minute? 10 minutes?

MaxBQb commented 3 years ago

Less than minute

Druzai commented 3 years ago

Added this feature in new release