/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to doc/en/admin-guide/backup.txt

  • Committer: Robert Collins
  • Date: 2010-05-11 08:36:16 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100511083616-b8fjb19zomwupid0
Make all lock methods return Result objects, rather than lock_read returning self, as per John's review.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
The features that make Bazaar a good distributed version control system also
45
45
make it a good choice for backing itself up.  In particular, complete and
46
46
consistent copies of any branch can easily be obtained with the ``branch`` and
47
 
``pull`` commands.  As a result, a backup process can simply run ``brz pull``
 
47
``pull`` commands.  As a result, a backup process can simply run ``bzr pull``
48
48
on a copy of the main branch to fully update that copy.  If this backup
49
49
process runs periodically, then the backups will be as current as the last
50
50
time that ``pull`` was run.  (This is in addition to the fact
57
57
::
58
58
 
59
59
  $ cd /var/backup
60
 
  $ brz branch bzr+ssh://server.example.com/srv/bzr/trunk
61
 
  $ brz branch bzr+ssh://server.example.com/srv/bzr/feature-gui
 
60
  $ bzr branch bzr+ssh://server.example.com/srv/bzr/trunk
 
61
  $ bzr branch bzr+ssh://server.example.com/srv/bzr/feature-gui
62
62
 
63
63
to create the branches on the backup server.  Then, we could regularly (for
64
64
example from ``cron``) do
66
66
::
67
67
 
68
68
  $ cd /var/backup/trunk
69
 
  $ brz pull  # the location to pull from is remembered
 
69
  $ bzr pull  # the location to pull from is remembered
70
70
  $ cd ../var/backup/feature-gui
71
 
  $ brz pull  # again, the parent location is remembered
 
71
  $ bzr pull  # again, the parent location is remembered
72
72
 
73
73
The action of pulling from the parent for all branches in some directory is
74
 
common enough that there is a plugin to do it.
 
74
common enough that there is a plugin to do it.  The `bzrtools`_ plugin
 
75
contains a ``multi-pull`` command that does a ``pull`` in all branches under a
 
76
specified directory.
 
77
 
 
78
.. _bzrtools: http://launchpad.net/bzrtools
 
79
 
 
80
With this plugin installed, the above periodically run commands would be
 
81
 
 
82
::
 
83
 
 
84
  $ cd /var/backup
 
85
  $ bzr multi-pull
 
86
 
 
87
Note that ``multi-pull`` does a pull in *every* branch in the specified
 
88
directory (the current directory by default) and care should be taken that
 
89
this is the desired effect.  A simple script could also substitute for the
 
90
multi-pull command while also offering greater flexibility.
75
91
 
76
92
Bound Branch Backups
77
93
~~~~~~~~~~~~~~~~~~~~
78
94
 
79
 
When ``brz pull`` is run regularly to keep a backup copy up to date, then it
 
95
When ``bzr pull`` is run regularly to keep a backup copy up to date, then it
80
96
is possible that there are new revisions in the original branch that have not
81
97
yet been pulled into the backup branch.  To alleviate this problem, we can set
82
98
the branches up so that new revisions are *pushed* to the backup rather than
86
102
is set up on the server itself rather than on the backup machine.  For each
87
103
branch that should be backed up, you just need to use the ``bind`` command to
88
104
set the URL for the backup branch.  In our example, we first need to create
89
 
the branches on the backup server (we'll use ``brz push``, but we could as
90
 
easily have used ``brz branch`` from the backup server)
 
105
the branches on the backup server (we'll use ``bzr push``, but we could as
 
106
easily have used ``bzr branch`` from the backup server)
91
107
 
92
108
::
93
109
 
94
110
  $ cd /srv/bzr/projectx/trunk
95
 
  $ brz push bzr+ssh://backup.example.com/var/backup/trunk
 
111
  $ bzr push bzr+ssh://backup.example.com/var/backup/trunk
96
112
  $ cd ../feature-gui
97
 
  $ brz push bzr+ssh://backup.example.com/var/backup/feature-gui
 
113
  $ bzr push bzr+ssh://backup.example.com/var/backup/feature-gui
98
114
 
99
115
and then we need to bind the main branches to their backups
100
116
 
101
117
::
102
118
 
103
119
  $ cd ../trunk
104
 
  $ brz bind bzr+ssh://backup.example.com/var/backup/trunk
 
120
  $ bzr bind bzr+ssh://backup.example.com/var/backup/trunk
105
121
  $ cd ../feature-gui
106
 
  $ brz bind bzr+ssh://backup.example.com/var/backup/feature-gui
 
122
  $ bzr bind bzr+ssh://backup.example.com/var/backup/feature-gui
107
123
 
108
124
A branch can only be bound to a single location, so multiple backups cannot
109
125
be created using this method.  
143
159
but when it came time to restore from backups, finding out that the backups
144
160
themselves were flawed.  As such, it is important to check the quality of the
145
161
backups periodically.  In Bazaar, there are two ways to do this: using the
146
 
``brz check`` command and by simply making a new branch from the backup.  The
147
 
``brz check`` command goes through all of the revisions in a branch and checks
 
162
``bzr check`` command and by simply making a new branch from the backup.  The
 
163
``bzr check`` command goes through all of the revisions in a branch and checks
148
164
them for validity according to Bazaar's internal invariants.  Since it goes
149
165
through every revision, it can be quite slow for large branches.  The other
150
166
way to ensure that the backups can be restored from is to perform a test
151
167
restoration.  This means performing the restoration process in a temporary
152
 
directory.  After the restoration process, ``brz check`` may again be relevant
 
168
directory.  After the restoration process, ``bzr check`` may again be relevant
153
169
for testing the validity of the restored branches.  The following two sections
154
170
present two restoration recipes.
155
171
 
181
197
  $ cd /srv
182
198
  $ mv bzr bzr.old
183
199
  $ cd bzr
184
 
  $ brz branch bzr+ssh://backup.example.com/var/backup/trunk
185
 
  $ brz branch bzr+ssh://backup.example.com/var/backup/feature-gui
 
200
  $ bzr branch bzr+ssh://backup.example.com/var/backup/trunk
 
201
  $ bzr branch bzr+ssh://backup.example.com/var/backup/feature-gui
186
202
 
187
203
If there are multiple backups, then change the URL above to restore from the
188
204
other backups.