[mythtv-users] backup script -- remove old backups.

G Venkataraman gvenkat at gmail.com
Fri Oct 26 22:12:09 UTC 2007


On 10/26/07, Mitch Gore <mitchell.gore at gmail.com> wrote:
>
> hi,
>
> I have a cron job that does a daily backup of my DB.  I dont want these
> backups to build up so i want to delete the old ones.  I would like to keep
> a back log of 3 days.  I wrote this script and it used to work but its not
> anymore.
>
>
> ------------------------------------------------------------------------------------------------------------------
> FN=mythtv_backup-$(date +%Y-%m-%d_%H:%M).sql
> DIR=/mythbackups
>
> mysqldump -u mythtv -pmythtv mythconverg -c > $DIR/$FN
>
> # bzip our db backup so it takes alot less space
> bzip2 $DIR/$FN
>
> #delete any backup files that status haven't changed for over 3 days.
> rm $(find $DIR -ctime +3 -name "mythtv_backup*")
>
> #copy the backups to my frontend just in case a HDD crash
> scp /mythbackups/* myth at 192.168.0.203:/mythbackups
> ------------------------------------------------------------------------------------------------------------------
>
>
> For some reason my find isnt working anymore....
>
>
> ------------------------------------------------------------------------------------------------------------------
> [myth at mythtv mythbackups]$ find /mythbackups -ctime +3 -name
> "mythtv_backup*"
> [myth at mythtv mythbackups]$ ls -l
> total 22992
> -rw-r--r-- 1 root root 2972304 Oct 22 04:47 mythtv_backup-2007-10-22_04:
> 47.sql.bz2
> -rw-r--r-- 1 root root 3114204 Oct 23 04:47 mythtv_backup-2007-10-23_04:
> 47.sql.bz2
> -rw-r--r-- 1 root root 3384627 Oct 24 04:49 mythtv_backup-2007-10-24_04:
> 48.sql.bz2
> -rw-r--r-- 1 root root 3533711 Oct 25 04:47 mythtv_backup-2007-10-25_04:
> 47.sql.bz2
> -rw-r--r-- 1 root root 3496667 Oct 26 04:47 mythtv_backup-2007-10-26_04:
> 47.sql.bz2
> -rw-rw-r-- 1 myth myth 3500124 Oct 26 15:20 mythtv_backup-2007-10-26_15:
> 20.sql.bz2
> -rw-rw-r-- 1 myth myth 3500095 Oct 26 15:22 mythtv_backup-2007-10-26_15:
> 22.sql.bz2
> ------------------------------------------------------------------------------------------------------------------
>
>
> Any ideas what the issue is?
>
> Thanks,
> Mitchell


Have you tried using "mtime" instead of "ctime" ? "ctime" indicates the time
when the file's meta information (owner, permissions, etc.) was changed.
"mtime" indicates the last modify time ("ls -l" displays this mtime value in
its output). In any case, you can also look at the actual ctime values of
the files by using "ls -lc" command and examine what those times are (and
find out the reason for the files not being removed).

-=Venkat=-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mythtv.org/pipermail/mythtv-users/attachments/20071026/394650e7/attachment-0001.htm 


More information about the mythtv-users mailing list