Sign in

transfer posts from one Publii site to another?

  • This topic has 7 replies, 3 voices, and was last updated 7 months ago by .
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #7204
    Avatar photocaddo1975

    Is there an easy way to transfer, copy/paste posts from one Publii “site” to another?

    Example: I have several posts contained only in “site A” that I wish to add to either a new or existing “site B”.

    I tried simply copy/pasting the post file folders from Publii\sites\[site A]\input\media\posts, yet that did not work. The posts did not show in the admin/editor area, afterwards.

    I’m sure this is likely a no-brainer, but I’m still getting acquainted with Publii, so I likely missed it. Thank in advance for the help.

    #7205
    Avatar photoBob

    You can duplicate the whole page, not the selected posts.

    --
    Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!

    #7216
    Avatar photocaddo1975

    You can duplicate the whole page, not the selected posts.

    Thanks, Bob. When you say, “duplicate”, do you mean make a COPY of the post WITHIN the same “site”? If so, that’s not quite what I had in mind.

    I need to transfer several dozen posts from one Publii site to another.

    If that’s not what you meant, can you clarify, as I’m not ‘getting’ it. Cheers!

    #7218
    Avatar photoBob

    I mean copying the entire site.
    Thre is no option to move the selected post to another site.

    --
    Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!

    #7219
    Avatar photocaddo1975

    I mean copying the entire site.

    Thre is no option to move the selected post to another site.

    Ugh. I was afraid of that. Thanks again for taking time to answer, Bob. Cheers.

    #7239
    Avatar photojammpub

    TBH, if I had to transfer tons of posts from one site to another site, other than duplicating the entire site as Bob indicated and then deleting the posts you don’t want (which overall might be the fastest way to do it), I’d also consider creating a custom tool/script that deals with the SQLite databases directly.

    Publii uses SQLite to contain the post content, and it wouldn’t be hard to write a script to do what you are asking. Care would have to be taken of how to handle the post IDs (from what I can tell by quickly glancing at the database) so you don’t mess them up, but in theory, I’m guessing it’s a pretty doable script, even for me, and I’m pretty rusty. I haven’t programmed for years, but if I was desperate or very curious I might try it. I don’t have the time to do it right now, but I imagine an experienced coder familiar with SQLite could knock out something simple in a handful of hours, way faster than I could. So it might not be worth the time or expense to do that, compared to just manually copying over the posts. Again, it’s still probably faster to just duplicate the site and delete the posts you don’t want, since such a script will take time to develop.

    This is all just theoretical of course, and if I had to do this myself I might write a script that would be ugly and messy, lol, but it would be mostly straightforward SQL queries, and it would be limited to my test scenario, and I’d have to figure out how IDs are affected, so I might be digging myself a big hole and pull my hair out wondering why I would waste my time. But I imagine the devs could probably add this feature without too much headache, but they’d also want to make it beautiful, test it thoroughly, and make sure it works across many test cases. So in that sense it could take a lot time either way and be a big headache and probably not worth it. But I wonder if they are open to accepting donations to sponsor features? Might be worth asking if that might be worth it to you. I’d imagine it’s a low priority otherwise since the number of people who might need that feature is likely low compared to other features that are on the dev’s roadmap.

    But anyway, the post data itself is cleanly organized inside SQLite databases, and you can actually browse the databases with a tool like DB Browser for SQLite (an open source project located at https://sqlitebrowser.org/ ). There might be some other open source SQLite tool out there that could actually help you do the job too, or perhaps export posts in the format that would make it easier to re-import them into the new site. That’s the beauty of open source software — there are probably tons of ways to do what you want.

    I know my post doesn’t help much, but one of the great things about Publii is that it uses open standards and pretty clean file structures so the possibilities are endless, it’s just whether or not an existing solution will do what you need, or you are willing to invest time/resources into helping make a feature a reality.

    #7240
    Avatar photojammpub

    BTW, I should add that it *might* be possible to do what you want to do right inside DB Browser for SQLite (again, https://sqlitebrowser.org/ ) — come to think of it, it does a lot more than browse SQLite databases. It allows you to edit databases, import/export, run queries, etc… it’s pretty powerful. So *maybe* it could help you do the job. You might not need a custom script after all. But you’d have to become very familiar with how posts are structured in Publii to use it safely, and possibly learn some SQL, otherwise you might damage your sites.

    A quick look at the structure of the posts table in the SQLite database reveals that Publii keeps the posts very simply structured, with just ID, TITLE, AUTHORS, SLUG, TEXT, FEATURED_IMAGE_ID, and a few other fields. Nice and clean IMO. With a lot of care, you might be able to selectively export and then import to do what you want. Again, watch out for how IDs work, but in theory, it could be possible to use DB Browser of SQLite to get the job done.

    #7370
    Avatar photocaddo1975

    appreciate the additional thoughts @jampub. while I check this out, doing so might be more effort than the few posts we have to transfer. thanks, tho!

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.