Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 230
  • Last Modified:

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!
0
timhyoung
Asked:
timhyoung
  • 8
  • 5
1 Solution
 
gripeCommented:
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.
0
 
timhyoungAuthor Commented:
Hosting provider only will provide a weekly tar.  Is there a script I could run to tar them myself daily?
0
 
gripeCommented:
timhyoung,

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.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
gripeCommented:
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')
0
 
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.
0
 
gripeCommented:
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?
0
 
gripeCommented:
You could ask your hosting provider which files/directories they provide and then just mimic the same command they use.
0
 
timhyoungAuthor Commented:
yes all the files are in my home directory
0
 
timhyoungAuthor Commented:
once i login to my ssh could i type " pwd " ... would that help?
0
 
gripeCommented:
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. :)
0
 
timhyoungAuthor Commented:
can i also add --exclude /subdirectory/  
I dont want to backup the subdirectory which has all the logs - due to its size
0
 
gripeCommented:
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

0
 
gripeCommented:
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.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 8
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now