How to make archive of drupal database with a php code inside node? Without any scripts. This needs in case you forget your FTP access.

  • Can you make your question a bit clearer? I have no clue what you are trying to do and what your problem is.
    – googletorp
    Commented Jun 29, 2011 at 8:25
  • For example: i have a user with id==1, how can i make a copy of site's database using php code inside a node, then download it. In case i've forgot ftp and phpmyadmin logins. Commented Jun 29, 2011 at 8:51

1 Answer 1


There is a module for this, use that instead of custom coding PHP in nodes. Generally you never want to put code in nodes for a lot of reasons:

  • No version control.
  • If you make a syntax error you're in big troubles.
  • very hard to maintain when you need to upgrade a site (API changes).
  • Greater possibility to open your site for security vulnerabilities.
  • ...

Anyways the module backup and migrate will do what you need.

Alternative solution

If you don't have DB password or FTP password and want to create a dump, the simplest thing you can do it to:

  1. get the DB password from Drupal

    global $db_url;
  2. Use the password obtained from Drupal to login to PHPmyadmin or similar
  3. Use the GUI to create the dump.
  • Sorry, but i won't use a module for that task. So you have no idea about this? Commented Jun 29, 2011 at 8:57
  • 1
    @Heihachi You can copy/paste the code from the module. But after seeing what's needed you might want to reconsider. Any reason why you don't want to use a module?
    – googletorp
    Commented Jun 29, 2011 at 9:00
  • in order to install a module, you need FTP access, which the OP has not.
    – berkes
    Commented Jun 29, 2011 at 10:16
  • @Heihachi If you don't have the passwords needed, check my alternative solution.
    – googletorp
    Commented Jun 29, 2011 at 10:43
  • I have database password, database name and host adress. But i cant login to phpmyadmin, because i can't find the link Commented Jul 1, 2011 at 4:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.