Restore directory to previous state

6,543

Reverse the RSYNC. So swap around dir1 and dir1.back then add the delete flag to ensure it removes files as appropriate to make sure it properly syncs and not just ignore files that weren't present in dir1 originally.

rsync -avz --delete dir1.bak/ dir1/
Share:
6,543

Related videos on Youtube

Gilles 'SO- stop being evil'
Author by

Gilles 'SO- stop being evil'

Updated on September 18, 2022

Comments

  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' over 1 year

    I have an approximately 1TB directory with subdirectories dir1. I have made an rsync backup copy dir1.back.

    How can I efficiently restore dir1 to the state of dir1.back - that is, replace files in dir1 with those of dir1.back if they've change and deleting any new files in dir1? Given its large size, cp/rsync of the entire dir1.back is highly infeasible.

    If I'm not mistaken, this might be possible using rsync --check-sum?