CrossFTPBackup/Scheduling with CrossFTP Commander

CrossFTP Commander is a command line tool based on CrossFTP engine to handle data transfer, sync, and backup operations. It is a component of CrossFTP Enterprise.

This manual guides you to do file and database backup & scheduling by CrossFTP Commander with easy.

LinuxMac OS Xwindows Download Portable Package

Evaluate
Buy

 

Backup

Scheduling

Backup

This section introduces the script guide to do one-time backup task based on CrossFTP Commander. Please check the corresponding sub-sections for details.

File Backup

The file backup script is available at the /scripts/ subdirectory in the downloaded package.

  • For windows -backup_file.bat
  • For Mac/Linux - backup_file.sh

To make it work, you need to change the variables in the script's step (1) first. The following is the sample variables of backup_file.bat in this step:

set JAVA_HOME=\path\to\JavaHome
set COMMANDER_HOME=\path\to\crossftp-all-bin
set SOURCE_FILE_PATH=\path\to\source\file
set TARGET_SITE_ID=ID
set TARGET_FILE_PATH=/path/to/target/file.%ISO_TIMESTAMP%

Here is an example of changed variables:

set JAVA_HOME=c:\Program Files\Java\jdk1.8.0_151
set COMMANDER_HOME=c:\JDK\crossftp-all-bin
set SOURCE_FILE_PATH=c:\JDK\readme.txt
set TARGET_SITE_ID=1527321342558
set TARGET_FILE_PATH=/crossftp/backup/readme.txt.%ISO_TIMESTAMP%

After changing the variable values, run the script to test if the backup works as expected.

For windows, go to the scripts directory and execute:

.\backup_file.bat

For Mac/Linux, go to the scripts directory and:

Make sure the script is executable:

chmod +x backup_file.sh

After that, execute the script:

./backup_file.sh

Directory Backup

The directory backup script is available at /scripts/ subdirectory in the downloaded package.

  • For windows -backup_dir.bat
  • For Mac/Linux - backup_dir.sh

To make it work, you need to change the variables in the script's step (1) first. The following is the sample variables of backup_dir.bat in this step:

set JAVA_HOME=\path\to\JavaHome
set COMMANDER_HOME=\path\to\crossftp-all-bin
set SOURCE_DIR=\path\to\source\dir
set TARGET_SITE_ID=ID
set TARGET_DIR=/path/to/target/dir.%ISO_TIMESTAMP%

Here is an example of changed variables:

set JAVA_HOME=c:\Program Files\Java\jdk1.8.0_51
set COMMANDER_HOME=c:\JDK\crossftp-all-bin
set SOURCE_DIR=c:\totalcmd
set TARGET_SITE_ID=1527321342558
set TARGET_DIR=/crossftp/backup/totalcmd.%ISO_TIMESTAMP%

After changing the variable values, run the script to test if the backup works as expected.

For windows, go to the scripts directory and execute:

.\backup_dir.bat

For Mac/Linux, go to the scripts directory and:

Make sure the script is executable:

chmod +x backup_dir.sh

After that, execute the script:

./backup_dir.sh

MySQL Backup

The MySQL backup script is available at /scripts/ subdirectory in the downloaded package.

  • For windows -backup_mysql.bat
  • For Mac/Linux - backup_mysql.sh

To make it work, you need to change the variables in the script's step (1) first.

After changing the variable values, run the script to test if the backup works as expected.

For windows, go to the scripts directory and execute:

.\backup_mysql.bat

For Mac/Linux, go to the scripts directory and:

Make sure the script is executable:

chmod +x backup_mysql.sh

After that, execute the script:

./backup_mysql.sh

Scheduling

Windows

Use Task Scheduler to schedule the script run. See this article for the details (link). In the "Start a Program" step, select the backup script, e.g., c:\path\to\backup_dir.sh

Mac/Linux - Crontab

On Mac/Linux/Unix, you can use the system built-in crontab, which is a scheduling tool that will run jobs (scripts) at regular intervals.

You add a job to crontab by editing the job list. A job is specified in the following format (first line):

* * * * *  command to execute
│ │ │ │ │
│ │ │ │ └─── day of week (0 - 6) (0 to 6 are Sunday to Saturday)
│ │ │ └──────── month (1 - 12)
│ │ └───────────── day of month (1 - 31)
│ └────────────────── hour (0 - 23)
└─────────────────────── min (0 - 59)

For example, if you want to use cronjobs to make regular backups of a directory using backup_dir.sh, you can set it up to run as cronjob by editing the job list (with any editor, e.g., nano):

env EDITOR=nano crontab -e

Now enter the following and press CTRL+O and CTRL+X to save and exit.

0 12 * * *  /path/to/backup_dir.sh

This will execute the command every day at 12:00, which backups your directory.

To see a list of your active crontab jobs, use the following command:

crontab -l

Disable Mail Alerts

After you've set up your scripts in cronjob, you might notice that the Terminal suddenly have started sending you e-mails. You can disable this behavior by inserting this line at the very top of your crontab file:

Here's a few other cronjob examples which might come in handy:

Description
Script
Execute on workdays 1AM
0 1 * * 1-5 /path/to/script.sh
Execute every 10 minutes
*/10 * * * * /path/to/script.s

References:

[1] Schedule jobs with crontab on Mac OS X (link)

[2] Scheduling Tasks with Cron Jobs (link)

Reviews