#53 Do not modify ctimes

closed
nobody
None
5
2012-01-18
2012-01-17
Anonymous
No

Would it be possible for the script not to change the ctimes of the backup files? This is because after I've dove the backup another program moves those files offsite. To determine what needs to be moved, it looks the ctimes of the files and thus sees that all files have changed instead of just the latest ones.

Discussion

  • PittaGurneyi
    PittaGurneyi
    2012-01-17

    Let me guess ... you have
    chown root.root /var/backup/db* -R
    find /var/backup/db* -type f -exec chmod 400 {} \;
    find /var/backup/db* -type d -exec chmod 700 {} \;
    in your cron file ...
    This here is what changes your ctimes. Just take it out or try (depending on your OS and filesystem) to use mtimes instead. Those - at least for my system - aren't changed by chown and chmod. If the mtimes are changed by chmod and chown this might even stop the backup rotation from working, if the program "find" on your os/filesystem combination works with ctimes instead of mtimes or mtimes are also changed by chmod/chown.

    Please get back to me with more information on your os/filesystem and what you find out.

     
  • PittaGurneyi
    PittaGurneyi
    2012-01-18

    • status: open --> closed
     
  • PittaGurneyi
    PittaGurneyi
    2012-01-18

    This is closed, because the script itself doesn't change ctimes (=last status change of inode), chmod and chown do, since the status includes permissions and ownership. However the right thing to compare times to is mtimes (=last modification of file CONTENTS).

    I'll leave comment posting open in case you choose to reply.

     

  • Anonymous
    2012-01-18

    D'oh! Almost spot on:

    chown -R root.root ${AMB_BACKUP_LOC}
    find ${AMB_BACKUP_LOC} -type f ! -perm 400 -execdir chmod 400 {} \;
    find ${AMB_BACKUP_LOC} -type d ! -perm 700 -execdir chmod 700 {} \;

    So I did remember to make sure that find does not change the ctimes but promptly foreget all about chown... Oh well, that's an easy fix.

    Sorry for the trouble.

     

  • Anonymous
    2012-01-18

    And for future reference, if someone wonders the same, this should help:

    find ${AMB_BACKUP_LOC} \( -type d -or -type f \) \( ! -user root -or ! -group root \) -execdir chown root.root {} \;
    find ${AMB_BACKUP_LOC} -type f ! -perm 400 -execdir chmod 400 {} \;
    find ${AMB_BACKUP_LOC} -type d ! -perm 700 -execdir chmod 700 {} \;