Get a filelist with all CHMOD details from webserver

Ok here is my current situation:

Dedicated managed server with FTP access.

I backup my site daily to a local machine; both MySQL db and files.

In the event that something happens to my site or I need to reproduce the site on another server how do I keep a listing of all my files CHMODs?

Im running a custom CMS with over 1000 files and all different varieties of CHMOD properties.

Is there a php,perl,or cgi script that could give me a file list of all files and their respective CHMOD values?

Is there an open source software package or FTP/Remote client software that I could run that would give me this listing?

Thanks for your help in advance!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Do you have the option of using a system utility to bundle your files beforehand? If so, use tar to bundle them into a single file. Tar will track your permissions and UID/GIDs for each file (Although UID/GID will be wrong if you restore on a system with different mappings.

Your managed hosting provider should be able to schedule a nightly tar of your files if you provide them with a list of directories and/or files you want.

This would definitely be the easiest way to go about this. No sense reinventing the wheel with a script.
timhyoungAuthor Commented:
Hosting provider only will provide a weekly tar.  Is there a script I could run to tar them myself daily?

Sure, if you have access to the crontab on the server, you could do it just by scheduling a tar command with the arguments of the directories you want to add.

For instance, if you want to tar up /home/httpd and /usr/local/db you'd add the following entry to cron:

0 0 * * * /usr/bin/tar -cvf /home/your-user/backup.tar /usr/local/db /home/httpd

The 0 0 means run at the 0th minute of the 0th hour (so 12 midnight) and the '*'s mean every day, month, and day of the week.

The command is '/usr/bin/tar'
The '-c' option means 'create an archive'
The '-v' option means 'verbose output'
The '-f' option means 'create in the following file' (In this case /home/your-user/backup.tar)
The rest of the entries are directories you want to back up.

Tar will back up the directories recursively and maintain both path and permissions information.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

A couple caveats:

- Make sure you have enough space to store all of the data you're tar'ing up in the location you specify it to create the file. tar does not compress, it just bundles. You could use a compression program on the created tar file if you want to save on space. (gzip for example)
- cron will by default email you the output of your whatever you run in it. In this case it will email your user account with a listing of all the files you archived. If you don't want any output append:

2>&1 1>/dev/null

to the end of the above command. (redirect all output to null or 'nowhere')
timhyoungAuthor Commented:
ok thanks for your help so far...I logged in via SSH via putty

crontab -e

inserted the following: 0 0 * * * /usr/bin/tar -cvf /home/your-user/backup.tar /usr/local/db /home/httpd

::For you-user I changed that to my username for SSH::

Then I saved the cron

when I type crontab -l I see it listed there

I just want to make sure that it is backing up the corrent directories...
Is /usr/local/db and /home/httpd the default directories or could they be different on my webserver?  Is there a way I could find them out?

Thanks a lot in advance again gripe.
Yes, and you probably should remove that command in the meantime.. those were just examples. When you log in with FTP to back up your files, which ones are you backing up? Are they all in your home directory?
You could ask your hosting provider which files/directories they provide and then just mimic the same command they use.
timhyoungAuthor Commented:
yes all the files are in my home directory
timhyoungAuthor Commented:
once i login to my ssh could i type " pwd " ... would that help?
yes, pwd should tell you.

Also, if you want to tar the same directory that you'll be creating your '.tar' file in, you'll want to exclude that file. For instance, if you name your .tar file 'backup.tar' as in the example above, add --exclude backup.tar to your command switches so that you don't try to backup your backup. :)
timhyoungAuthor Commented:
can i also add --exclude /subdirectory/  
I dont want to backup the subdirectory which has all the logs - due to its size
yes, you can add as many of those as you like:

/usr/bin/tar -cvf backup.tar /home/your-user --exclude /home/user/backup.tar --exclude /home/user/subdirectory

If you have shell access, you might also want to review the 'man' page for tar. Just to familiarize yourself with the command.

Just type: man tar

at your command prompt.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.