Hello,
I'm trying to help someone who is on bad terms with their current host/web developer. I have admin access into drupal, so I can use the backup/migrate module to get the database, but without ftp server access, is there another way to get the site files and theme files (basically everything under /sites/*)?

Thanks for your help.

Comments

vm’s picture

you can't get the files with backup migrate, that soley for the database at this time.

you either get the files from FTP (which you don't have) or use the host panel and download them with thier file manager.

kruser’s picture

Right, I have the DB. But there has to be some outside of the box way to get at the files.

-----------------------------------------------------
Bob @ Drupal Aid (https://www.drupalaid.com)

cog.rusty’s picture

At least for the files which are readable from the web, and you know where they are, you could write a shell script on your own machine to browser with wget or something and get them.

For the rest, you might be able to loosen them up first with some PHP in Drupal, depending on what "write" access the webserver has on files which you own (for writing in .htaccess files and/or for renaming files)

Either that, or he could pay up.

dman’s picture


passthru("tar -czf /tmp/default-backup.tgz sites/default ");
passthru("mv /tmp/default-backup.tgz sites/default/files/default-backup.tgz");
print l("Backup now available", 'sites/default/files/default-backup.tgz');

dman’s picture

Just don't do it too many times, it will get exponentially bigger unless you remove the old backup first.
...
In fact, lets fix that.

passthru("rm sites/default/files/default-backup.tgz ");
passthru("tar -czf /tmp/default-backup.tgz sites/default ");
passthru("mv /tmp/default-backup.tgz sites/default/files/default-backup.tgz");
print l("Backup now available", 'sites/default/files/default-backup.tgz');

..safe!

mcfilms’s picture

I nominate this to be in the PHP snippets of Drupal.org. Could this be in the body of a php-enabled node and then only give permission to admins to access said node? Is that how you would use it? Would it make more sense to create a module from this?

Thanks!

A list of some of the Drupal sites I have designed and/or developed can be viewed at motioncity.com

dman’s picture

The security issues are bigger than can be dealt with in a snippet.
(You can get a database dump also with only another one line)

Making it a module would defeat the purpose somewhat, I like it like this.

It probably is worth a handbook page though :-)

mcfilms’s picture

So how would one USE this then? Would the ideal course be to just create a php page with this code, name it something like backup.php, upload it, open the page, pull down the backup and destroy the page on the server? It kind of defeats the purpose if you have to interact with the server anyway. The ideal would be to have this php on an admin-only page somewhere and allow the end-user administrator to occasionally pull down a copy of the site files. I thought I read this feature was making its way to the Backup and Migrate module, but I may be mistaken.

A list of some of the Drupal sites I have designed and/or developed can be viewed at motioncity.com

dman’s picture

mm.. no

Just paste it into a Drupal node content area, set input format to 'PHP' and 'preview' once.
Done.
If you want to do it repeatedly, save the page but don't publish it.

Access to this page as an admin only does NOT protect the existence or download of the site backup file (which includes your DB password in plaintext).
So it becomes a security hole. Quite a big, deliberate one :-)

The full feature does belong in backup_migrate #208213: Add ability to back up files directory or thereabouts http://drupal.org/project/backup_migrate_files

kruser’s picture

That's exactly what I needed!!! Thanks a lot, it worked great.

-----------------------------------------------------
Bob @ Drupal Aid (https://www.drupalaid.com)

kruser’s picture

You just need to make sure up update the path names.

ie:
sites/all
sites/default
sites/{site_directory}

Depending on permissions it may not grab everything.

-----------------------------------------------------
Bob @ Drupal Aid (https://www.drupalaid.com)

tmds’s picture

This works great for the code that you have posted but I am having difficulties using it to download anything in the sites/all folder. I have changed the path names but still not working. Please advise.

Thanks in advance.

dman’s picture

To get sites/all

passthru("rm sites/default/files/sites-all-backup.tgz ");
passthru("tar -czf /tmp/sites-all-backup.tgz sites/all ");
passthru("mv /tmp/sites-all-backup.tgz sites/default/files/sites-all-backup.tgz");
print l("Backup now available", 'sites/default/files/sites-all-backup.tgz');

To get everything under sites/* as requested, just change the path in line 2

tmds’s picture

Thanks very much, it works perfectly!