Search
Project
General
Profile
Home
Projects
Help
Sign in
Register
Search
:
Redmine
All Projects
Redmine
Overview
Download
Activity
Roadmap
Issues
News
Wiki
Plugins
Forums
Repository
Download (1.19 KB)
RE: Hardware requirements
» svn-backup2.php
Bruno Prado
, 2010-01-12 17:02
#!/usr/bin/php5 -q
<?php
# Requires PHP5 or the file_put_contents() function from PEAR::Compat
# this is a directory with my svn repositories in it
$source_dir
=
"/var/svn"
;
# this is where the svn dumps will go
$dest_dir
=
"/mnt/server/DS/SVN"
;
# we only back up repositories which have changed
$hashfile
=
"/tmp/hash/hashes.txt"
;
$date
=
system
(
"date +%Y-%m-%d"
);
# read in the existing hash file if there is one
$hashes
=
array
();
$hashlines
=
array
();
if
(
file_exists
(
$hashfile
))
{
$hashlines
=
file
(
$hashfile
);
}
# build this into an useful array
foreach
(
$hashlines
as
$hashline
)
{
$key
=
substr
(
$hashline
,
0
,
strpos
(
$hashline
,
":"
));
$value
=
substr
(
$hashline
,
strpos
(
$hashline
,
":"
)
+
1
);
if
(
$key
&&
$value
)
{
$hashes
[
$key
]
=
$value
;
}
}
# Compress repositories folder
system
(
"tar -cf
$dest_dir
/
$date
.tar
$source_dir
/*"
);
# Remove oldest backup
# system("find $dest_dir -amin +6000 -exec rm '{}'");
system
(
"find
$dest_dir
-amin +6000 -exec rm '{}' \ "
);
$hashelines
=
""
;
foreach
(
$hashes
as
$key
=>
$md5
)
{
$hashelines
.
=
"
$key
:
$md5
\n
"
;
}
file_put_contents
(
$hashfile
,
$hashelines
);
?>
« Previous
1
2
Next »
(2-2/2)
Loading...