-2

I am developing a WordPress 5.2.3 site. My provider offers Plesk Obsidian 18.0.21 as admin tool. I want to store the custom PHP source code and the image upload area on a private GitHub repository. Images are currently too few to justify an autonomous storage solution, like S3 or similar. I am not concerned about the DB used by WP, because its backups are already well managed.

I am new to WP development and I am unsure which directories must be preserved on the GitHub repository, so I decided to store on GitHub the whole httpdocs area of my server.

I have performed the following operations:

  • installed WP from my Plesk console

  • zipped the whole lot from the Plesk file manager

  • downloaded the zipfile on my PC

  • created an empty repo on GitHub

  • cloned the GitHub repo on my PC

  • expanded the zipfile in the local repo on my PC

  • committed the new files and pushed to GitHub

  • deleted the files on the server using the Plesk file manager

  • from the Plesk console, enabled Git for my domain and linked it to the GitHub repo

  • on GitHub I have installed the public key provided by Plesk, allowing both read and write access to the repo

The clone performed by Plesk went smoothly: all the files from the remote GitHub repo have been copied, I can see on the Plesk console that the git log reports every commit, and the WP site works perfectly.

Now I have uploaded a test image from the WP admin dashboard, the directory uploads shows the new image file in the Plesk file manager, and now I wish to push it to GitHub.

I enter the httpdocs directory with an SSH shell, but there is no trace of a .git directory. I try git status and the answer is not a git repository.

Has Plesk performed a real git clone, or has it just created a directory that allows GitHub hooks to fire and copy files there?

I may be possibly doing things the wrong way, but I have basically two needs:

  • develop PHP code (widgets, custom post types, etc.)

  • upload images from the WP admin dashboard

Both these assets must be versioned on GitHub.

I understand that I can develop the PHP code on my PC, push it on GitHub and have the hooks bring the changes on my Plesk-managed server. But I cannot envision a workflow for storing on GitHub the uploaded images, because they originate from the Plesk-managed server.

Is there a best practice for addressing both these needs at the same time in my environment?

5
  • Git is not a database. You shouldn't try to be versioning files uploaded to WordPress with git. You should find a another solution. Commented Feb 9, 2020 at 19:27
  • @StephenOstermiller - Absolutely disagree with your advice. Git is meant to store files, which is exactly what it's happening here: I want to version PHP code and images. Your observation that it's not a database is completely beside the point: not even the WP team has thought of storing its assets in a database! Commented Feb 10, 2020 at 7:57
  • Git is a version control system. It works best for versioning text content. You can put binary files such as images into it, but it doesn't do well at that task (it stores full copies of each version.) It is meant to be used by humans and not in an automated fashion. Any job that tries to automatically commit and push changes from your live site on a schedule is going to fail occasionally due to conflicts or timing of commits from other places. Git would be great for your PHP code, but you should use archiving and backup software for database dumps and images. Commented Feb 10, 2020 at 10:30
  • 1
    I use mysqldump and rsync to backup the database and files created by my WordPress sites. Commented Feb 10, 2020 at 10:31
  • Push of new material to GitHub is done manually by me after developing the site. rsync is indeed good advice. I plan to use it the day that images become too many. I modified my question to depict the fact that that day is still far, far away. For MySQL backups I trust Plesk completely. Commented Feb 10, 2020 at 17:34

1 Answer 1

0

I reckon I may have posted something too specific. I thought that talking about version control using Plesk in a webmasters' Q&A site would trigger more attention (that's why I didn't post on the StackExchange WordPress site), but most attention went indeed on WordPress. Ok, too bad.

Having to solve the problem by myself, I came to the conclusion that Git support in Plesk is too limited.

With Plesk I can have local copies of remote Git repositories, but they are just supposed to pull. Any changes created on the Plesk server cannot be pushed to the remote; this flies in the face of WordPress, which by default stores media assets locally.

Therefore, I removed all the Git stuff I had arranged in the Plesk console, got with SSH into my Plesk server, initialized a Git repository in httpdocs, pushed it to GitHub and was done with it.

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