htaccess file is wiped out after running pkgacct

Optimizr

Active Member
Aug 8, 2020
36
6
8
Yangon
cPanel Access Level
Root Administrator
I am running a custom script for the backup schedule and transportation but the backup is handled by /scripts/pkgacct. I am having strange error that every time the schedule backup has ran, the htaccess file of a lo of sites are emptied. They all became 0kb.

So I went ahead to check /scripts/pkgacct file and I found following block

Perl:
If the server is running EasyApache4, it may have added some clauses
into vhosts' .htaccess files, which we want to strip out.  The target
server could be an EasyApache3 host, and won't have the same handlers
set, or could be an EasyApache4 host, but may not have the same set of
PHPs installed, and our PHP handler could very well cause the vhost to
simply stop serving pages.

Since we're using Archive::Tar::Builder to create the tar, and we can
do any sort of mapping that we like, we'll copy our .htaccess files
into the work directory, change their names, and return the remapping.
The caller will need to alter the mapping, to send things into the
$workdir/homedir tree, but this should be simple.

If the server is not running EasyApache4, we will return without
performing any action.
I am using EA4. I am mostly running WordPress sites and thus .htaccess file are needed with at least WordPress's default. For now, I run a script that find 0kb htaccess file and put the WordPress's default configurations back after the backup script. But this is unneeded extra step. Please tell me how can I fix this issue.
 
Last edited by a moderator:

andrew.n

Well-Known Member
Jun 9, 2020
460
119
43
EU
cPanel Access Level
Root Administrator
Make sure the htaccess files has the correct permissions and ownerships which in most of the cases causing the problem.
 
  • Like
Reactions: Optimizr

andrew.n

Well-Known Member
Jun 9, 2020
460
119
43
EU
cPanel Access Level
Root Administrator
@cPRex ?

@Optimizr can you paste here or attach the full backup logs? so we can see what else it can be.
 
  • Like
Reactions: Optimizr

wintech2003

Well-Known Member
PartnerNOC
Sep 15, 2010
103
27
78
Greece
cPanel Access Level
DataCenter Provider
chmod 666 means that all users can read/write this file. The proper permissions are 644 for files, 755 for folders.
You can perform a bulk change of permissions by running the following while in the public_html folder.
Code:
find . -type d -exec chmod 0755 {} \;
find . -type f -exec chmod 0644 {} \;
(that said, I don't know why having the "wrong" permissions would empty your .htaccess file, so yeah definitely something that the cPanel techs need to take a closer look)
 
  • Like
Reactions: Optimizr

Optimizr

Active Member
Aug 8, 2020
36
6
8
Yangon
cPanel Access Level
Root Administrator
chmod 666 means that all users can read/write this file. The proper permissions are 644 for files, 755 for folders.
You can perform a bulk change of permissions by running the following while in the public_html folder.
Code:
find . -type d -exec chmod 0755 {} \;
find . -type f -exec chmod 0644 {} \;
(that said, I don't know why having the "wrong" permissions would empty your .htaccess file, so yeah definitely something that the cPanel techs need to take a closer look)
Thank you for pointing out. When @andrew.n mentioned this I just had a quick check on other working file and they are also at 666 permission. That's why I though 666 was intentional for htaccess (although I know 644 is recommended for files).

I will run a quick fix for all those htaccess file and will get back with the outcome. My backup is running on alternate days. Therefore, forgive me if my reply is taking a while.
 

andrew.n

Well-Known Member
Jun 9, 2020
460
119
43
EU
cPanel Access Level
Root Administrator
Nice, keep us updated!
 

Optimizr

Active Member
Aug 8, 2020
36
6
8
Yangon
cPanel Access Level
Root Administrator
Looks like fixing the permission of .htaccess did the magic. I only have one emptied .htaccess file today which I must have left out while fixing the permission. Thank you all for your helps. Have a good day ahead!
 
  • Like
Reactions: cPRex