Configuration Rollback
Commit Confirmed
There is a feature called commit confirmed that gives JunOS an edge. If you make a mistake in your config, you might lose access to the device or cause issues requiring a visit.
With JunOS, you can use commit confirmed, and if you don't lock in the commit, it rolls back your changes.
Syntax commit confirmed MINUTES
Run another commit to lock in the changes.
Config files
Committing stores a backup config in /config every time you commit a change.
You can view the directory with
file list /config
Or for more detail:
file list /config detail
The file named juniper.conf.gz is the active configuration file. The ones labeled .1, .2, .3, are previous changes.
There are additional backups in /var/db/config. In smaller devices this may be in /config/db/config.
Rollback
If you are writing a config file and realize you need to revert, use rollback, or rollback 0. This loads the active config as the candidate config.
If you accidentally committed first, you can rollback to a different point to the amount of commits you want to go back in time, such as rollback 2
Remember that this only loads it in as the active, you still have to commit the change after rolling back.
If you want to compare the candidate to a backup, you can use
show | compare rollback x

If you want, you can manually back up the candidate config to disk using save myconfig.conf