While working on a ticket and not ready to commit, it's a good idea to backup all of our changes to an archive file.
The following script does all that and executed daily by cronjob automatically.
Make the file executable:
The following script does all that and executed daily by cronjob automatically.
- create a file, say "backup" in /etc/cron.daily
- Type the following (change '
<yourhome directory>
' to your own login name and <git location> to the git directory where source codes are located):
backing up changed files to tarball
#!/bin/sh pushd <your source-code location> LIST=`git status --porcelain | sed -n -e '/^ [D|M]/p' | sed -e 's/^ [D|M] //' ` backupname=`git branch | sed -n -e "/^* /p" | sed -e 's/** //' ` backupname=$backupname-` date "+%s" `.backup. tar .bz2 dest= '
if [ ! -d "$dest" ] then mkdir -p $dest fi tar jcvf $dest/$backupname $LIST > /dev/null |
Make the file executable:
chmod +x /etc/cron.daily/backup
No comments:
Post a Comment