Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7028369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:22:41+00:00 2026-05-28T00:22:41+00:00

$filename= Backup.tar; // The name (and optionally path) of the dump file $ftp_server =

  • 0
$filename= "Backup.tar";   // The name (and optionally path) of the dump file 
$ftp_server = "IP";      // Name or IP. Shouldn't have any trailing slashes and shouldn't be prefixed with ftp:// 
$ftp_port = "21";   // FTP port - blank defaults to port 21 
$ftp_username = "User";      // FTP account username 
$ftp_password = "Pass";      // FTP account password - blank for anonymous 
$filename = "public_html/backups/" . $filename . ".gz"; 

$command = "tar cvf ~/$filename ~/*"; 
$result = exec($command); 

$command = "gzip -9 -S .gz ~/$filename"; 
$result = exec($command); 

This is my working backup that I use. It backs up everything on the server including emails (for example /mail/. I only want to backup the /public_html folder and all subdirectories under it. It creates a tar.gz file in the /public_html/backups/ folder. The PHP script also runs from the /public_html/backups/ folder. Any idea on how to restrict what is saved from ‘/’ to ‘/public_html/’ ? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:22:41+00:00Added an answer on May 28, 2026 at 12:22 am

    you just need to change the third input of the tar command

    $filename= "Backup.tar";   // The name (and optionally path) of the dump file 
    $ftp_server = "IP";      // Name or IP. Shouldn't have any trailing slashes and shouldn't be prefixed with ftp:// 
    $ftp_port = "21";   // FTP port - blank defaults to port 21 
    $ftp_username = "User";      // FTP account username 
    $ftp_password = "Pass";      // FTP account password - blank for anonymous 
    $filename = "public_html/backups/" . $filename . ".gz"; 
    
    $command = "tar cvf ~/$filename /public_html/*"; 
    $result = exec($command); 
    
    $command = "gzip -9 -S .gz ~/$filename"; 
    $result = exec($command); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having issues with compressing folders via tar on shell backup script. # Path to
I have to list all the information available inside a zip file (FileName, lenght,
i have this code (on the fly compression and stream) @cherrypy.expose def backup(self): path
I have a file server backup on an external hard drive a few months
I have checked in the same file (filename) twice in 2 different branches (say,
filename = Path.GetFileName(FileUpload.FileName); HttpPostedFile pf = FileUpload.PostedFile; System.Drawing.Image img2 = System.Drawing.Image.FromStream(pf.InputStream); System.Drawing.Image bmp2 =
string fileName = test.zip; string path = c:\\temp\\; string fullPath = path + fileName;
I have a filename that can have multiple dots in it and could end
Possible Duplicate: Getting Filename from file descriptor in C Obtain filename from file pointer
I have a filename that leads to a picture. It is not an embedded

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.