Archives for the ‘Linux’ Category

【Linux】【MongoDB】 MongoDBでのバックアップとリストアについて

mongodump/mongorestoreコマンドを用いてMongoDBをバックアップとリストアする。 ・localhostのtest_dbをバックアップする mongodump –host localhost –db test_db ・localhostのtest_dbにあるtest_collectionをバックアップする mongodump –host localhost –db test_db –collection test_collection ・localhostのtest_dbにあるtest_collectionのユーザ”akio”をクエリ指定してバックアップする mongodump –host localhost –db test_db –collection test_collection -q {userName : ‘akio’} ・バックアップしたtest_dbを全てリストアする mongorestore –host localhost –db test_db ./dump/test_db ・バックアップしたtest_dbのtest_collectionをリストアする mongorestore –host localhost –db test_db –collection test_collection ./dump/test_db/test_collection.bson

【Linux】 tarコマンドでパーミッション保持したまま圧縮/解凍する

tarコマンドでパーミッション保持したまま圧縮/解凍するには「p」オプションを付ける また解凍時はroot権限などでないとパーミッションを持ったまま解凍できない模様。 # パーミッション保持したまま圧縮 tar cvzfp xxxxx.tar.gz ディレクトリ名 # パーミッション保持したまま解凍 tar xvzfp xxxxx.tar.gz