2

I've created a PHP-based document management system and hosted it on my Raspberry Pi. I created a "backup" function that zips together all the documents, but it takes too long due to the hardware constraints of the Pi, as well as the fact that compression cannot be disabled when creating zip files in PHP.

This has led me to think that perhaps I should just devise some sort of binary file format that allows multiple files to be stored in it, and dump all my uncompressed documents into it when the user asks for backups. Oddly, I'm not necessarily concerned about the lack of possible "unarchivers".

Which file format is the easiest to implement, whether a standard format, or a proposed new format?

Is there any other alternative for solving my problem that does not require implementing a custom archiver?

Note that I wish to avoid the following:

  • Shell commands (not portable).
  • Installing third party dependencies (may not work on a third party hosted system).
  • Rewriting my system in a different language.
  • 6
    It sounds like you might want something like TAR files, but if you don't want third-party dependencies, maybe you'll have to implement your own TAR library. – FrustratedWithFormsDesigner Jul 9 '14 at 15:08
  • 1
    You might insert files as blobs into an SQLite database. That'd give you direct access to read/write/update/delete files without having to roll your own format. – GrandmasterB Jul 9 '14 at 16:13
  • I second the suggestion for TAR files. Even if you choose to go without using a third-party TAR library, the format is very simple. Basically it's just a 512 byte header per file and the structure is header, file, header, file, etc. - no compression, intended to be friendly for tape backups and the like. – J Trana Jul 10 '14 at 5:24
  • 2
    tar is implemented in PHP by the PharData class. It is worth noting that the Single Unix Specification recommends pax as a replacement for tar and cpio. – mouviciel Jul 10 '14 at 8:36
2

The only solution I would consider for this problem is TAR. If you cannot find a PHP Tar implementation then implementing TAR in PHP saves you the time of designing your own format.

Although you are not interested in unarchivers, the fact that every OS of any real consequence has TAR tools means verifying your implementation becomes significantly easier.

I am not PHP programmer, but a quick Google search of PHP + TAR has enough hits to tells me a TAR solution is readily available in PHP, giving more reasons to us it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.