OMG!!! I deleted EVERYTHING!!!!

DaNewGuy

Member
May 12, 2010
14
0
51
Oh lord have mercy!

I have been working on a Zen Cart for weeks. Most all of my cart files are stored in the public_html. As I tweak my css or add a mod, I backup sql into a folder and then compress the content of my public_html. I then move the back up to a file above (or parrallel) to public_html.

A few moments ago, I was experimenting with css flyout menus, decided I hated it.

I went to do what I have done many times this month... delete the contents of public_html, the uncompress the backup file into public_html.

I wasn't paying attention as I got into File Manager, hit "Select All" and then "Delete".

It was then that I reallized I was in my ACCT folder (top level), not my public_html.


OMG I AM SO SCREWED!!!!!!!!

I checked the .trash file... it says: No records found


Please... anybody... is there anything that can be done??? I'm on a VPS. I have root level access if need be.
 

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,214
13
313
Houston, TX
cPanel Access Level
Root Administrator
..
Please... anybody... is there anything that can be done??? I'm on a VPS. I have root level access if need be.
If you enabled automatic server backups (WHM -> Backup -> Configure Backup), backups may be found in /cpbackup (that's cpbackup in /, not ~, on your server) if you were doing local (rather than remote) backups.
 

DaNewGuy

Member
May 12, 2010
14
0
51
DavidG,

I don't know how the WHM backup is configured. I know I get a weekly backup. Going to check WHM -> Backup right now (at both root and acct level). Thanks for your help!

+++

Kris,

I don't know what you mean by /backup folder. If you are being specific to Zen Cart (there is such a folder), then the only thing in that folder was sql. I kept all my other backups (the entire home/user/public_html folder) above at the user level (home/user/backupzzz).

But I was in the user (home/user) when I hit select all and then deleted!

Is there somewhere else I can look for your /backup folder? Perhaps at a root level?
+++

QUESTION: I hit delete, then INSTANTLY realized the gravity of my error. I did NOTHING else. The only thing I have done is to check the .trash file. Why is it gone? I checked that folder about 60 seconds after the mistake, nothing was in it.

What is the point of having a trashcan if deleted stuff doesn't go into it?
 

DaNewGuy

Member
May 12, 2010
14
0
51
Is there a way to tunnel in and search for deleted files? I know the name of my last backup.

Can I do a grep to look specifically for deleted files?
 

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,214
13
313
Houston, TX
cPanel Access Level
Root Administrator
QUESTION: I hit delete, then INSTANTLY realized the gravity of my error. I did NOTHING else. The only thing I have done is to check the .trash file. Why is it gone? I checked that folder about 60 seconds after the mistake, nothing was in it.

What is the point of having a trashcan if deleted stuff doesn't go into it?
In the Legacy File Manager, when files are "moved to the trashcan", they are moved to ~/.trash. Unfortunately, in this event, if you were viewing (hidden) dot-files, ~/.trash was also deleted - causing the trashcan to be empty.
 

cPanelDon

cPanel Quality Assurance Analyst
Staff member
Nov 5, 2008
2,545
12
268
Houston, Texas, U.S.A.
cPanel Access Level
DataCenter Provider
Twitter
Is there a way to tunnel in and search for deleted files? I know the name of my last backup.

Can I do a grep to look specifically for deleted files?
To attempt recovery of permanently deleted files -without backups- I believe it would require special tools or applications, such as hard drive data recovery software or certain utilities commonly used in computer forensics.

However, if automated cPanel Backups are enabled via WHM and configured to backup accounts then it is possible to search for the desired account backups via root SSH access, i.e., command-line interface (CLI) access to a remote console or terminal via SSH.

For Windows, a common and free SSH client is PuTTY, and a free FTP-like file manager tool that may help WinSCP and this can also be used to launch PuTTY sessions. For Mac OS X, there is a built-in program named Terminal.app, accessed via /Applications/Utilities/, that can be used for command-line access to a remote system via SSH.

Via root, command-line SSH access (e.g., via PuTTY), enter the following command to locate the cPanel backup directory path:
Code:
# grep BACKUPDIR /etc/cpbackup.conf
A common path used is "/backup" as configured using WHM via the following menu path: WHM: Main >> Backup >> Configure Backup

If located in "/backup" here is an example of the directory structure:
Code:
/backup
/backup/cpbackup
/backup/cpbackup/daily
/backup/cpbackup/weekly
/backup/cpbackup/monthly
The following example command will search within the BACKUPDIR path for files or directories that have a name containing the string "username"; "username" may be changed to any word you wish to search for:
Code:
# find /backup -iname "*username*"
To perform the same search, but skip having to use grep, the following example could be used instead, while ensuring to replace "username" with the desired username or filename to locate:
Code:
# find $(awk '/BACKUPDIR/ { print $2 }' /etc/cpbackup.conf) -iname "*username*"
To attempt locating only the top-level per-user sub-directory or per-user backup archive, both of which are named after the cPanel account username, try the following example that includes the use of the CLI switch "--maxdepth 3" for the utility "find" when searching the BACKUPDIR path so that it will use a maximum directory depth of 3 levels, matching the depth that should normally contain the per-user cPanel account backups for daily, weekly, and monthly intervals; in this command, replace "username" with the desired cPanel account username search for:
Code:
# find $(awk '/BACKUPDIR/ { print $2 }' /etc/cpbackup.conf) -maxdepth 3 -iname "*username*"
 

Spiral

BANNED
Jun 24, 2005
2,018
8
193
Please... anybody... is there anything that can be done??? I'm on a VPS. I have root level access if need be.
Possibly --- who is your server provider?

Some server providers keep daily hard drive snapshot images
 

DaNewGuy

Member
May 12, 2010
14
0
51
Thank you all so much for your help!

At this point I have pieced together most all of my work that I deleted. But I have one question before moving forward:
What do I do about all those folders that had been generated by whm/cpanel?

When I hit delete, I was in the HOME directory of MYSITE.com and I deleted all of the following folders:
etc
mail
public_ftp
public_html

There may have been more folders, those are the only ones I recall off hand. I managed to get "mail" to come back back by going into WHM and "upgrading" the account.

Can I simply create my own folders for:
etc
public_ftp
public_html
 

Spiral

BANNED
Jun 24, 2005
2,018
8
193
What do I do about all those folders that had been generated by whm/cpanel?

When I hit delete, I was in the HOME directory of MYSITE.com and I deleted all of the following folders:
etc
mail
public_ftp
public_html
So I presume then that your provider wasn't successful restoring backups?

Regarding your public_ftp and public_html --- those are easy ....

Code:
# cd /home/[i]login[/i]
# mkdir -- ./public_html ./public_ftp
# chown [i]login[/i]:nobody -- ./public_html
# chmod 0750 -- ./public_html
# chown [i]login[/i]:[i]login[/i] -- ./public_ftp
# chmod 0755 -- ./public_ftp
Your /etc and /mail folders are a bit more complicated as those each of account specific files contained in them.

There is also /tmp, /ssl, and a slew of hidden folders in the account

You could also try creating a backup and see about rebuilding the account using the standard packaging tools:
Code:
# /scripts/pkgacct [i]login[/i]
(This creates a full backup archive in /home as 'cpmove-login.tar.gz' that could be used to rebuild the account)

Before making any major changes to any hosting account, I also always
like to run the 'pkgacct' tool just to create 'restore point' that I can fall
back on to be able to undo any mistakes like what you just did.

I know that helps you little in retrospect but perhaps useful for the future.
 

cPanelDon

cPanel Quality Assurance Analyst
Staff member
Nov 5, 2008
2,545
12
268
Houston, Texas, U.S.A.
cPanel Access Level
DataCenter Provider
Twitter
Thank you all so much for your help!

At this point I have pieced together most all of my work that I deleted. But I have one question before moving forward:
What do I do about all those folders that had been generated by whm/cpanel?

When I hit delete, I was in the HOME directory of MYSITE.com and I deleted all of the following folders:
etc
mail
public_ftp
public_html

There may have been more folders, those are the only ones I recall off hand. I managed to get "mail" to come back back by going into WHM and "upgrading" the account.

Can I simply create my own folders for:
etc
public_ftp
public_html
It is possibly to manually recreate any missing directories via cPanel File Manager, via FTP access, or -preferably- via root SSH access. The sub-directories "~/etc/" and "~/mail/" will be automatically created upon recreating any e-mail accounts that may have been setup; if separate (add-on) FTP accounts were setup I would also attempt to recreate those as well.

I believe an ideal solution would be to restore from a full cPanel-account backup, using either root SSH access or via WHM. Restoring from a full cPanel account backup, such as one created before the loss of data, will ensure all missing directory structure is properly restored.

If no existing full account backup is available, another option you may consider is to recreate the account itself, either by removing and recreating it via WHM, or by generating a fresh full account backup and restoring from there (such as what was suggested in another thread reply).

For mail-related directories, the following script should help alleviate permission issues, executed via root SSH access:
Code:
# /scripts/mailperm --verbose
The "public_html" directory can be recreated either manually or using the following script:
Code:
# /scripts/rebuildhttpdconf
The following script should apply correct ownership and permissions to the "public_html" directory:
Code:
# /scripts/chownpublichtmls
Here is an example command to create the "public_ftp" directory, (where "username" should be replaced with the applicable cPanel account username):
Code:
# mkdir -pv ~username/public_ftp
# chown -v username:username ~username/public_ftp
Here is an example to create the missing "www" symbolic link (symlink):
Code:
# cd ~username
# ln -fnsv public_html www
# chown -hv username:username www
 

DaNewGuy

Member
May 12, 2010
14
0
51
Awesome, thank you so much cPanelDon!

I should have updated this thread because the situation ended up getting resolved a couple days ago.

But I will add your words to my bag of tricks for future reference and hope I never need it.

Though I no longer need it, this thread will someday help the next poor guy who does the same foolish thing I did.

Thank again!
 

damainman

Well-Known Member
Nov 13, 2003
515
0
166
The following script should apply correct ownership and permissions to the "public_html" directory:
Code:
# /scripts/chownpublichtmls
I was under the impression"# /scripts/chownpublichtmls" was no longer valid, via it NOT showing on this page which says:
Do not use a script within the /scripts directory if it is not listed here. Executing such a script may damage your server.
- WHM Scripts
 

cPanelDon

cPanel Quality Assurance Analyst
Staff member
Nov 5, 2008
2,545
12
268
Houston, Texas, U.S.A.
cPanel Access Level
DataCenter Provider
Twitter
I was under the impression"# /scripts/chownpublichtmls" was no longer valid, via it NOT showing on this page which says:

- WHM Scripts
It is correct that certain scripts are not listed (or not yet listed); however, the listing is not intended to infer that all other scripts are invalidated nor is it intended to infer a status of deprecation of scripts not explicitly listed.

We are continuously working to expand and improve the documentation so you may see future additions or changes to the aforementioned page; however, I cannot guarantee if the script mentioned will or will not be added.

If you have any specific suggestions or requests for our documentation please use the dedicated Feedback area that is accessible via the (red or blue) link located in the middle of the vertical edge on the right side of each documentation page.
 

damainman

Well-Known Member
Nov 13, 2003
515
0
166
Thank you for reply :). I asked because it use to be on the list, but when it got removed from the list I stopped using it because I thought it was no longer valid.