Skip to main content
Home
The Baheyeldin Dynasty
The journey for wisdom starts with knowledge
  • Home
  • About
  • Site Map
  • Contact

Quick Tips: How to copy/archive a Drupal site with only FTP access

  1. Home

By Khalid on 2008/07/05 - 01:46, last updated 2008/07/05 - 02:14

I do most of my work using ssh and other command line tools, such as vim and screen. This is the environment I am most comfortable and productive in.

However, this is not always an option working on client sites. Some do not have ssh enabled for various reasons, including hosting restrictions (e.g. shared hosting) or security concerns and workplace policies.

So, in these situations, it is hard to replicate the site on a test server for an assessment, development work, or moving the site from an old server to a new one.

The following are some techniques that I use when I need to copy a site quickly.

Using cPanel

If the site in question has cPanel, you can use phpMyAdmin to backup the database, and either save it to a file, or directly download it to your desktop. That takes care of the database part, what about the files then?

For the files, you can use cPanel's cron interface to run a command like the following after 2 minutes from present time:

cd ~/public_html; tar -czvf BACKUP.tar.gz . 

Wait for the two minutes to pass, then using FTP or cPanel's File Manager, download the archive that was created.

Using a temporary PHP script

Instead of using web based interfaces, which can be clumsy, you can use FTP to upload a custom PHP script that executes shell commands on your behalf.

First, download the settings.php file for the site. In it, there will be the database name, the use name and password for the site.

Second, take the above information and create a PHP file like this one. Replace the capitalized values with those you just gleaned from the settings file.

<?php
exec("mysqldump -uDBUSER -pPASSWORD DBNAME > DBNAME.sql");
exec("tar -czvf BACKUP.tar.gz .");
print "Done"; 

Name the file something unique and unguessable, such as a timestamp or a random number (e.g. 74688266024.php). Make sure that it ends in .php.

Upload this file using FTP to the public_html directory for your site. Then point your browser to it (e.g. http://example.com/74688266024.php), and wait till the backup completes.

Now, delete the php file you just created, so no one else can run the script.

After that, download the tar achive using FTP, and delete it and the database dump too.

Drupal Modules

There are several Drupal modules that provide backup and restore facilities to varying degrees. One such module is backup,  dba, and backup_migrate. You can use one of them to create the backup you need and then download it.

However, this requires extra steps like uploading the Drupal module, enabling it, configuring it, running the backup, then disabling/deleting the module.

What other tricks for copying/replicating a site do you use if you encounter a restrictive environment?

Contents: 
Drupal
  • Add comment

Comments

Caroline Schnapp (not verified)

Hoooo I like this.

Sat, 2008/07/05 - 13:12

I really like your 'Using a temporary PHP script' trick. Bookmarked.

  • reply

Gerhard Killesreiter (not verified)

lftp

Sun, 2008/07/06 - 16:15

lftp is a neat programm that can be used to up and download whole directories when executed from the commandline. The best thing about it is that it is scriptable.

  • reply

AoC Gold (not verified)

RE: Temporary Php script excellent

Wed, 2008/08/27 - 14:22

I like using the temporary PHP script , very well explained and of course working !

Thanks for the trick,

Andy

  • reply

Current

Pandemic

  • COVID-19
  • Coronavirus

Search

Site map

Contents

  • Family
    • Khalid
    • Ancestry
    • Extended
  • Friends
  • Nokat نكت
  • Writings
    • Cooking
    • Culture
    • Science
    • History
    • Linguistics
    • Media
    • Literature
    • Politics
    • Humor
    • Terrorism
    • Business
    • Philosophy
    • Religion
    • Children
  • Technology
    • Linux
    • Arabization
    • Drupal
      • Association
    • Software
    • Internet
    • Technology in Society
    • Digital Archeology
    • NCR History
    • MidEast Internet
    • Programming
    • Saudi ISPs
    • Miscellaneous
  • Places
    • Canada
      • Weather
    • Egypt
      • Cuisine
      • Alexandria
      • E.G.C.
    • USA
    • Saudi Arabia
  • Interests
    • Astronomy
    • Fishing
    • Photography
    • Snorkeling
    • Nature
    • Photomicroscopy
  • Miscellany

In Depth

  • al-Hakim bi Amr Allah: Fatimid Caliph of Egypt الحاكم بأمر الله
  • Alexandria, Egypt
  • Arabic on the Internet
  • Articles on the history of Muslims and Arabs in the Iberian Peninsula تاريخ المسلمين و العرب في الأند
  • DIY GOTO Telescope Controller With Autoguiding and Periodic Error Correction
  • E.G.C. English Girls College in Alexandria, Egypt
  • Egyptian Cuisine, Food and Recipes مأكولات مصرية
  • George Saliba: Seeking the Origins of Modern Science?
  • Internet Scams and Fraud
  • Mistaken for an Arab or Muslim: Absurdities of being a victim in the War on Terror
  • Mistaken Identity: How some people confuse my site for others
  • One People's Terrorist Is Another People's Freedom Fighter
  • Overview of Google's Technologies
  • Photomicroscopy
  • Pseudoscience: Lots of it around ...
  • Resources for using Google Adsense with Drupal
  • Rockwood Conservation Area, Southern Ontario
  • Selected Symbolic Novels And Movies
  • Snorkeling the Red Sea near Jeddah
  • Updates and Thoughts on the Egyptian Revolution of 2011

Recent Content

Most recent articles on the site.

  • Origin Of COVID-19: Natural Spillover, Lab Leak Or Biological Weapon?
  • Kamal Salibi and the "Israel from Yemen" theory
  • How To Upgrade HomeAssistant Core In A Python Venv Using uv
  • Ancestry - Paternal Side
  • Review of Wait Water Saver For Whole House Humidifiers
more

Most Comments

Most commented on articles ...

  • Another scam via Craigslist: offering more than asking price
  • Warning to female tourists thinking of marrying Egyptians
  • Craigslist classified for used car: Cheque fraud scam
  • Winning the lottery scam email: World Cup South African lottery
  • Email Scam: BMW 5 Series car and lottery winning
more

About Khalid

Various little bits of information ...

  • Khalid Baheyeldin: brief biography
  • Presentations and Talks
  • Youtube Videos
  • GitHub Projects
  • Drupal.org Profile
  • Astrophotography @ Flickr

Sponsored Links

Your Link Ad Here

Tags

Android Mobile Ubuntu Sony OnStep OpenWRT Router Ericsson COVID-19 Rogers Coronavirus Arabic Kubuntu Home Assistant GSM Telescope tablet Spectrum Scam Python 419 Laptop Firefox DIY CPU Conspiracy Comet Balkanization backup App
More

© Copyright 1999-2025 The Baheyeldin Dynasty. All rights reserved.
You can use our content under the Terms of Use.
Please read our privacy policy before you post any information on this site.
All posted articles and comments are copyright by their owner, and reflect their own views and opinions, which may not necessarily be consistent with the views and opinions of the owners of The Baheyeldin Dynasty.

Web site developed by 2bits.com Inc.