News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

SMF backup tool

Started by Sebastiii, May 25, 2022, 05:12:12 AM

Previous topic - Next topic

Sebastiii

Hi,

I would like to create a tool that save some page of the forum in "mHTML" format.
Why doing this, it's because to have a copy of a specific thread if somehow the forum stop to work.

So the idea, would be a tool that connect to the specific thread and start to saved as "mhtml" format each page.
The user should put his login/pass and URL link to the specific thread and doing start and the backup will be made.

I don't want to create direct access to db for security reason, but don't want to have spam too.
Only a read only backup thread function.

But login part seems tricky and in fact looks good.
So my favorite language is C# even if I'm not a good coder, but I would like to know if you can give me some idea ;)

Thanks.

Doug Heffernan

Quote from: Sebastiii on May 25, 2022, 05:12:12 AMI would like to create a tool that save some page of the forum in "mHTML" format.
Why doing this, it's because to have a copy of a specific thread if somehow the forum stop to work.

So the idea, would be a tool that connect to the specific thread and start to saved as "mhtml" format each page.
The user should put his login/pass and URL link to the specific thread and doing start and the backup will be made.

Unless I misunderstood, you can not make a backup of topics in this way. Its contents are stored in the database and not files. You can not make a partial backup of a single topic(s), you will have to make a backup of the whole database.

Sebastiii

Quote from: Doug Heffernan on May 25, 2022, 06:14:02 AMUnless I misunderstood, you can not make a backup of topics in this way. Its contents are stored in the database and not files. You can not make a partial backup of a single topic(s), you will have to make a backup of the whole database.
If from Chrome or Edge, you can save the current loaded page in .mhtml format :)
Then when opening it, you have a full copy of the page, and it's needed to do this for all page of the topic and save it with incremental number, like this we can read back the topic offline too, but the purpose is for the backup.

For ex here, just do a right click and use "Save-as" function and select mhtml, you can see that if you open this page, you have a backup of the current page :)

The idea would be to automate this from a tool :)

Kira_

        header("Content-Type: application/vnd.ms-word");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("content-disposition: attachment;filname.doc");

If you put this before starting the output, the page will not be rendered, but will be downloaded and opened in MS Word.

Next, it remains to place the button and track its click, for example, through $_SESSION or $_GET.

To save the entire topic, you can play with the number of messages on the page.
а нас
за що?

Sebastiii

Hi @Kira_
Thanks for your answer, so you mean that I must create a plugin based on your information and add a button to save the topic ?

Effectively, a button to backup the topic would be a great idea too :)

Aleksi "Lex" Kilpinen

Just going to point out the obvious here, but if I needed a specific topic backed up, I would just print the topic as pdf from the print view https://www.simplemachines.org/community/index.php?action=printpage;topic=582467.0

Another option would be a mirror install offline, and making regular database backups.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Kira_

Quote from: Sebastiii on May 25, 2022, 11:16:13 AMHi @Kira_
Thanks for your answer, so you mean that I must create a plugin based on your information and add a button to save the topic ?

Effectively, a button to backup the topic would be a great idea too :)

I didn't quite understand your task.
This method allows you to open a page in ms word on the user's device instead of displaying it on the screen. Then you can link it to a button, make a separate plugin, etc.
а нас
за що?

Sebastiii

Thanks @Aleksi "Lex" Kilpinen (oh mention is not correctly coded, so it seems ;) )
In fact, in our forum, we share information in a specific topic by the user create, so if the forum is down, it's nice for the user to keep track of what he has written.

The save as to PDF is an option, but the "mhtml" format is better, ;) it acts like it's the forum online.
Ofc the backup is done on server side all the night, but what I can try to achieve is the user itself can download his topic (for ex 300 pages) and to do it automatically.

Like @Kira_ said we can change number of message per topic to reduce page to backup too.

Sebastiii

Quote from: Kira_ on May 25, 2022, 11:33:43 AMI didn't quite understand your task.
This method allows you to open a page in ms word on the user's device instead of displaying it on the screen. Then you can link it to a button, make a separate plugin, etc.
Ok, thanks for confirming, the task I would achieve is to make this automatically (click the button, name the file when we have more than one page).

I will try to see the result of the ms-word design, "mhtml" don't need to have word (preview or msoffice installed for ex too).

Aleksi "Lex" Kilpinen

Quote from: Sebastiii on May 25, 2022, 11:41:54 AMThanks @Aleksi "Lex" Kilpinen (oh mention is not correctly coded, so it seems ;) )
@SleePy @Sesquipedalian - Which one of you broke it? :P
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Kira_

Quote from: Sebastiii on May 25, 2022, 11:45:12 AMI will try to see the result of the ms-word design, "mhtml" don't need to have word
The design is exactly the same as on the screen.
With mht is more complicated.
1. file_get_contents('http://...');
2. Process, for example, with this https://github.com/mrstacy/html2mht
3. Give the result to the user as file.
а нас
за що?

Advertisement: