svn backup via rake.. easier way to obtain lastest rev?

Discussion in 'Ruby' started by Simon Strandgaard, Jul 22, 2005.

  1. I have made a small script that makes a backup of
    a subversion repository.. with outputfiles formatted as:
    backup20050722_rev68.gz

    But I wonder if there is a smarter way to determine what
    the last revision?

    --
    Simon Strandgaard


    require 'open3'

    task :default =3D> :svnbackup

    task :svnbackup do
    =09repos =3D '/Users/simonstrandgaard/code/svnrepos'

    =09dummyfile =3D 'backuptmp'
    =09
    =09cmd =3D "svnadmin dump #{repos} | gzip -9 > #{dummyfile}"
    =09si, so, se =3D Open3.popen3(cmd) #do |stdin, stdout, stderr|
    =09si.close=20

    =09se_res =3D ''
    =09so_res =3D ''
    =09t1 =3D Thread.start do
    =09=09while line=3Dso.gets
    =09=09=09so_res << line
    =09=09=09puts "stdout: #{line}"
    =09=09end
    =09end
    =09t2 =3D Thread.start do
    =09=09while line=3Dse.gets
    =09=09=09se_res << line
    =09=09=09puts "stderr: #{line}"
    =09=09end
    =09end
    =09t1.join
    =09t2.join
    =09so.close
    =09se.close
    =09
    =09#p so_res, se_res
    =09ary =3D se_res.scan(/Dumped\srevision\s(\d+)\./m)
    =09rev =3D '_rev' + ary.flatten.last
    =09
    =09#p rev
    =09filename =3D 'backup' + Time.now.strftime('%Y%m%d')
    =09filename +=3D rev
    =09filename +=3D '.gz'

    =09mv(dummyfile, filename)
    end
    Simon Strandgaard, Jul 22, 2005
    #1
    1. Advertising

  2. Simon Strandgaard

    Cristi BALAN Guest

    On 7/22/05, Simon Strandgaard <> wrote:
    > I have made a small script that makes a backup of
    > a subversion repository.. with outputfiles formatted as:
    > backup20050722_rev68.gz
    >=20
    > But I wonder if there is a smarter way to determine what
    > the last revision?
    >=20
    > --
    > Simon Strandgaard
    >=20


    svnadmin youngest repos

    --=20
    Cristi BALAN
    Cristi BALAN, Jul 22, 2005
    #2
    1. Advertising

  3. On 7/22/05, Simon Strandgaard <> wrote:
    > On 7/22/05, Cristi BALAN <> wrote:
    > >
    > > svnadmin youngest repos

    >=20
    > Hmm.. my svnadmin does not support 'youngest'..
    > my svn+svnadmin versions is 1.1.3 (r12730).
    > however I just discovered svnlook..
    >=20
    > svnlook youngest repos
    >=20
    > 10x Thanks



    Code got reduced into this.

    --
    Simon Strandgaard



    require 'open3'

    task :default =3D> :svnbackup

    task :svnbackup do
    =09repos =3D '/Users/simonstrandgaard/code/svnrepos'

    =09revstr =3D `svnlook youngest #{repos}`
    =09rev =3D '_rev' + revstr.match(/\d+/).to_s
    =09#p rev

    =09filename =3D 'backup' + Time.now.strftime('%Y%m%d')
    =09filename +=3D rev
    =09filename +=3D '.gz'
    =09p filename

    =09sh "svnadmin dump #{repos} | gzip -9 > #{filename}"
    end
    Simon Strandgaard, Jul 22, 2005
    #3
  4. On 7/22/05, Cristi BALAN <> wrote:
    > On 7/22/05, Simon Strandgaard <> wrote:
    > > I have made a small script that makes a backup of
    > > a subversion repository.. with outputfiles formatted as:
    > > backup20050722_rev68.gz
    > >
    > > But I wonder if there is a smarter way to determine what
    > > the last revision?
    > >
    > > --
    > > Simon Strandgaard
    > >

    >=20
    > svnadmin youngest repos


    Hmm.. my svnadmin does not support 'youngest'..=20
    my svn+svnadmin versions is 1.1.3 (r12730).
    however I just discovered svnlook..

    svnlook youngest repos
    =20

    10x Thanks

    --
    Simon Strandgaard
    Simon Strandgaard, Jul 22, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gavino
    Replies:
    13
    Views:
    1,037
  2. Robert P. J. Day
    Replies:
    0
    Views:
    217
    Robert P. J. Day
    Jan 19, 2010
  3. Simon Strandgaard

    [ANN] Subversion Handy Backup, rev 8

    Simon Strandgaard, Feb 8, 2006, in forum: Ruby
    Replies:
    0
    Views:
    104
    Simon Strandgaard
    Feb 8, 2006
  4. peppermonkey
    Replies:
    1
    Views:
    237
    Gregory Brown
    Feb 10, 2007
  5. Jan Burse
    Replies:
    9
    Views:
    1,681
    Jan Burse
    May 8, 2012
Loading...

Share This Page