UP | HOME

Windows で cron + rsync でフルバックアップ

目次

1 環境

  • Windows 7 64bit
  • gnupackdevel-13.06-2015.11.08

2 手順

cron をサービスとして登録し、毎朝 4 時に / (ルート)から、/f/backup-cron/ へフルバックアップを行う。

$ apt-cyg install cron cygrunsrv
$ cron-config
The cron daemon can run as a service or as a job. The latter is not recommended.
Cron is already installed as a service under account .\cyg_server.
Installation path: E:\gnupack_devel-13.05-2015.07.19\app\cygwin\cygwin is not for this instance of Cygwin.
You must remove and reinstall the service to run in this instance.
Do you want to remove or reinstall it? (yes/no) yes
OK. The cron service was removed.

Do you want to install the cron daemon as a service? (yes/no) yes
Enter the value of CYGWIN for the daemon: [ ] 

You must decide under what account the cron daemon will run.
If you are the only user on this machine, the daemon can run as yourself.
   This gives access to all network drives but only allows you as user.
To run multiple users, cron must change user context without knowing
  the passwords. There are three methods to do that, as explained in
  http://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-nopasswd1
If all the cron users have executed "passwd -R" (see man passwd),
  which provides access to network drives, or if you are using the
  cyglsa package, then cron should run under the local system account.
Otherwise you need to have or to create a privileged account.
  This script will help you do so.
Do you want the cron daemon to run as yourself? (yes/no) yes

Running cron_diagnose ...
WARNING: You do not currently have a crontab file.

... no problem found.

Do you want to start the cron daemon as a service now? (yes/no) yes
OK. The cron daemon is now running.

In case of problem, examine the log file for cron,
/var/log/cron.log, and the Windows event log (using /usr/bin/cronevents)
for information about the problem cron is having.

Examine also any cron.log file in the HOME directory
(or the file specified in MAILTO) and cron related files in /tmp.

If you cannot fix the problem, then report it to cygwin@cygwin.com.
Please run the script /usr/bin/cronbug and ATTACH its output
(the file cronbug.txt) to your e-mail.

WARNING: PATH may be set differently under cron than in interactive shells.
         Names such as "find" and "date" may refer to Windows programs.

$ cygrunsrv -Q cron
Service             : cron                
Display name        : Cron daemon
Current State       : Running
Controls Accepted   : Stop
Command             : /usr/sbin/cron -n
$ export EDITOR='emacs -Q -nw'
$ crontab -e
$ cat /var/cron/tabs/username
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.TBl0oMz2r6 installed on Thu Nov 12 13:46:27 2015)
# (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)
0 4 * * * username rsync -xa --delete / /f/backup-cron
$ cygrunsrv --stop cron
$ cygrunsrv --start cron
$ cygrunsrv --query cron
Service             : cron                
Display name        : Cron daemon
Current State       : Running
Controls Accepted   : Stop
Command             : /usr/sbin/cron -n

3 参考

著者: clothoid

Created: 2021-10-09 Sat 11:11

Validate